-
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.
- Loading branch information
1 parent
5269da3
commit 35fce30
Showing
10 changed files
with
178 additions
and
34 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
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,37 @@ | ||
module HypertextTemplatesCommonMarkExt | ||
|
||
import CommonMark | ||
import HypertextTemplates | ||
import TOML | ||
|
||
function HypertextTemplates._handle_commonmark_ext( | ||
::HypertextTemplates.CommonMarkExtensionType, | ||
file, | ||
mod, | ||
suffix, | ||
) | ||
if !isfile(file) | ||
error("markdown template file does not exist: $file") | ||
end | ||
|
||
parser = CommonMark._init_parser(mod, suffix) | ||
rule = CommonMark.FrontMatterRule(; toml = TOML.parse) | ||
CommonMark.enable!(parser, rule) | ||
|
||
ast = open(parser, file) | ||
|
||
frontmatter = CommonMark.frontmatter(ast) | ||
name = basename(file) | ||
name, _ = splitext(name) | ||
name = get(frontmatter, "name", name) | ||
|
||
props = join(get(Vector{String}, frontmatter, "props"), " ") | ||
props = isempty(props) ? props : " $props" | ||
|
||
str = "<function $name$props>$(CommonMark.html(ast))</function>" | ||
return HypertextTemplates._components_from_str(str, file, mod) | ||
end | ||
|
||
function format_prop(k) end | ||
|
||
end |
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
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,3 @@ | ||
<h1 id="markdown-template"><a href="#markdown-template" class="anchor"></a>Markdown Template</h1><p>prop-value<em>content</em><strong>here</strong>.</p><pre><code class="language-julia">function test() | ||
return "test" | ||
end </code></pre> |
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,16 @@ | ||
+++ | ||
name = "custom-markdown-name" | ||
props = [ | ||
"prop" | ||
] | ||
+++ | ||
|
||
# Markdown Template | ||
|
||
<julia value=prop /> *content* **here**. | ||
|
||
```julia | ||
function test() | ||
return "test" | ||
end | ||
``` |