forked from AgregoreWeb/extension-agregore-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begun AgregoreWeb#8 ,added script for orgmode but hook does not trigger
Implemented Orgmode Rendering Cleaned up for patch
- Loading branch information
Showing
5 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,3 +109,4 @@ bundle-json.js | |
bundle-markdown.js | ||
bundle-ssb.js | ||
bundle-reader.js | ||
bundle-orgmode.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* global location */ | ||
import renderPage from './template.js' | ||
import { unified } from 'unified' | ||
import parse from 'uniorg-parse' | ||
import uniorg2rehype from 'uniorg-rehype' | ||
import stringify from 'rehype-stringify' | ||
|
||
export async function renderOrg (orgText) { | ||
const processor = unified() | ||
.use(parse) | ||
.use(uniorg2rehype) | ||
.use(stringify) | ||
|
||
const { value: html } = await processor.process(orgText) | ||
|
||
const { pathname } = location | ||
const filename = pathname.substring(pathname.lastIndexOf('/') + 1) | ||
|
||
// extract first heading as page title, fallback onto filename | ||
const pageTitle = html.match(/<h\d>([^<]+)<\/h\d>/)?.[1] || filename | ||
|
||
renderPage(html, pageTitle) | ||
} | ||
|
||
const text = document.querySelector('pre').innerText | ||
renderOrg(text) | ||
.catch(err => console.error('Rendering orgmode failed:', err)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters