-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from rcarmo/gfm
RFC: Markdown Rendering Support
- Loading branch information
Showing
9 changed files
with
170 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<html> | ||
|
||
<head> | ||
<link rel="stylesheet" type="text/css" href="main.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="main"> | ||
<h1>Namespace: joker.base64</h1> | ||
<span class="var-added">v1.0</span> | ||
<h2>Contents</h2> | ||
<ul> | ||
<li> | ||
<a href="#_summary">Summary</a> | ||
</li> | ||
<li> | ||
<a href="#_index">Index</a> | ||
</li> | ||
<li> | ||
<a href="#_constants">Constants</a> | ||
</li> | ||
<li> | ||
<a href="#_variables">Variables</a> | ||
</li> | ||
<li> | ||
<a href="#_functions">Functions, Macros, and Special Forms</a> | ||
</li> | ||
</ul> | ||
<h2 id="_summary">Summary</h2> | ||
<p class="var-docstr">Implements GitHub Flavored Markdown rendering.</p> | ||
<h2 id="_index">Index</h2> | ||
<ul class="index"> | ||
<li> | ||
<a href="#convert-string">convert-string</a> | ||
</li> | ||
</ul> | ||
<h2 id="_constants">Constants</h2> | ||
Constants are variables with <tt>:const true</tt> in their metadata. Joker currently does not recognize them as | ||
special; as such, it allows redefining them or their values. | ||
<ul> | ||
(None.) | ||
</ul> | ||
<h2 id="_variables">Variables</h2> | ||
<ul> | ||
(None.) | ||
</ul> | ||
<h2 id="_functions">Functions, Macros, and Special Forms</h2> | ||
<ul> | ||
<li> | ||
<h3 class="Function" id="convert-string">convert-string</h3> | ||
<span class="var-kind Function">Function</span> | ||
<span class="var-added">v1.0</span> | ||
<pre class="var-usage"><div><code>(convert-string s)</code></div></pre> | ||
<p class="var-docstr">Returns the HTML rendering of Markdown string s.</p> | ||
</li> | ||
</ul> | ||
</div> | ||
</body> | ||
<script src="main.js"></script> | ||
|
||
</html> |
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,10 @@ | ||
(ns | ||
^{:go-imports [] | ||
:doc "Implements GitHub Flavored Markdown rendering."} | ||
markdown) | ||
|
||
(defn ^String convert-string | ||
"Returns the HTML rendering of Markdown string s" | ||
{:added "1.0" | ||
:go "convertString(s)"} | ||
[^String s]) |
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,35 @@ | ||
// This file is generated by generate-std.joke script. Do not edit manually! | ||
|
||
package markdown | ||
|
||
import ( | ||
. "github.com/candid82/joker/core" | ||
) | ||
|
||
var __convert_string__P ProcFn = __convert_string_ | ||
var convert_string_ Proc = Proc{Fn: __convert_string__P, Name: "convert_string_", Package: "std/markdown"} | ||
|
||
func __convert_string_(_args []Object) Object { | ||
_c := len(_args) | ||
switch { | ||
case _c == 1: | ||
s := ExtractString(_args, 0) | ||
_res := convertString(s) | ||
return MakeString(_res) | ||
|
||
default: | ||
PanicArity(_c) | ||
} | ||
return NIL | ||
} | ||
|
||
func Init() { | ||
|
||
InternsOrThunks() | ||
} | ||
|
||
var markdownNamespace = GLOBAL_ENV.EnsureSymbolIsLib(MakeSymbol("joker.markdown")) | ||
|
||
func init() { | ||
markdownNamespace.Lazy = Init | ||
} |
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,22 @@ | ||
// This file is generated by generate-std.joke script. Do not edit manually! | ||
|
||
package markdown | ||
|
||
import ( | ||
"fmt" | ||
. "github.com/candid82/joker/core" | ||
"os" | ||
) | ||
|
||
func InternsOrThunks() { | ||
if VerbosityLevel > 0 { | ||
fmt.Fprintln(os.Stderr, "Lazily running slow version of markdown.InternsOrThunks().") | ||
} | ||
markdownNamespace.ResetMeta(MakeMeta(nil, `Implements GitHub Flavored Markdown rendering.`, "1.0")) | ||
|
||
markdownNamespace.InternVar("convert-string", convert_string_, | ||
MakeMeta( | ||
NewListFrom(NewVectorFrom(MakeSymbol("s"))), | ||
`Returns the HTML rendering of Markdown string s`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"})) | ||
|
||
} |
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,35 @@ | ||
package markdown | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/yuin/goldmark" | ||
"github.com/yuin/goldmark/extension" | ||
"github.com/yuin/goldmark/parser" | ||
"github.com/yuin/goldmark/renderer/html" | ||
) | ||
|
||
func convertString(source string) string { | ||
md := goldmark.New( | ||
goldmark.WithExtensions( | ||
extension.GFM, | ||
extension.Table, | ||
extension.DefinitionList, | ||
extension.Footnote, | ||
extension.Typographer, | ||
), | ||
goldmark.WithParserOptions( | ||
parser.WithAutoHeadingID(), | ||
), | ||
goldmark.WithRendererOptions( | ||
html.WithHardWraps(), | ||
html.WithXHTML(), | ||
html.WithUnsafe(), // allow for raw markup | ||
), | ||
) | ||
var buf bytes.Buffer | ||
if err := md.Convert([]byte(source), &buf); err != nil { | ||
panic(err) | ||
} | ||
return buf.String() | ||
} |