a8m / mark Goto Github PK
View Code? Open in Web Editor NEWA markdown processor written in Go. built for fun.
License: MIT License
A markdown processor written in Go. built for fun.
License: MIT License
Hey, how CommonMark is this?
Markdown parsers all seem to build their own unique flavor of Markdown each and every time, usually because they copy and paste around test suites from random other projects then miss updates and changes without noticing.
Sorry for the self link, but I wrote about the mess a bit here.
CommonMark would be awesome, especially if you work from their spec.
What ist the common way to set a line breake <br>
and a <hr>.
I tried
**What's new?** /
---
* The release notes now use HTML to look friendlier
* A lot of small improvements on Courier2
/There should be no visible changes for Courier 1 users.
in this code.
package main
import (
"fmt"
"io/ioutil"
"github.com/a8m/mark"
)
func main() {
markdown_text, err := ioutil.ReadFile("testdata/test3.md")
html := mark.Render(string(markdown_text))
fmt.Print(html, err)
}
But it dont set an <br>
after two spaces or an <hr>
for ---
.
I got this
</p>strong>Test This</strong>
</p> ---
<pre><code>
</code></pre>
<ul>
<li>Bla 1</li>
<li>Bla 2
Did it work?</li>
</ul><nil>
The parsing/rendering is broken for e.g
`my_variable_one`
which renders to
<code>my<em>variable</em>one</code>
it should
<code>my_variable_one</code>
My suggestion is to put the project in archive mode as it is not maintained since 2017 and link to a compliant tool like https://github.com/russross/blackfriday-tool
Kind regards,
Jerry
Upon running the tests with a --race
flag, you'll find the package is riddled with many race conditions. Due to this, the package cannot safely be utilized in any concurrent fashion.
I will only paste a snippet example here as the actual result errors totalled in over 3000 lines. A simple invocation of the tests with go test --race
should be sufficient enough to investigate.
WARNING: DATA RACE
Read at 0x00c42031d818 by goroutine 161:
github.com/a8m/mark.(*lexer).nextItem()
/Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:279 +0xb5
github.com/a8m/mark.(*parse).peek()
/Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:126 +0x154
github.com/a8m/mark.(*parse).parse()
/Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:38 +0x50
github.com/a8m/mark.(*parse).parseBlockQuote()
/Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:280 +0x194
github.com/a8m/mark.(*parse).parse()
/Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:59 +0x422
github.com/a8m/mark.(*Mark).Render()
/Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:45 +0x4d
github.com/a8m/mark.Render()
/Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:59 +0x5d
github.com/a8m/mark.TestCommonMark()
/Users/henryhenderson/go/src/github.com/a8m/mark/mark_test.go:1666 +0x14d
testing.tRunner()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:777 +0x16d
Previous write at 0x00c42031d818 by goroutine 447:
github.com/a8m/mark.(*lexer).next()
/Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:114 +0x138
github.com/a8m/mark.(*lexer).peek()
/Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:262 +0x3c
github.com/a8m/mark.lexText()
/Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:231 +0x78
github.com/a8m/mark.(*lexer).run()
/Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:101 +0xa1
Goroutine 161 (running) created at:
testing.(*T).Run()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:824 +0x564
testing.runTests.func1()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:1063 +0xa4
testing.tRunner()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:777 +0x16d
testing.runTests()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:1061 +0x4e1
testing.(*M).Run()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:978 +0x2cd
main.main()
_testmain.go:56 +0x22a
Goroutine 447 (running) created at:
github.com/a8m/mark.lex()
/Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:84 +0x112
github.com/a8m/mark.(*parse).parseBlockQuote()
/Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:279 +0xbe
github.com/a8m/mark.(*parse).parse()
/Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:59 +0x422
github.com/a8m/mark.(*Mark).Render()
/Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:45 +0x4d
github.com/a8m/mark.Render()
/Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:59 +0x5d
github.com/a8m/mark.TestCommonMark()
/Users/henryhenderson/go/src/github.com/a8m/mark/mark_test.go:1666 +0x14d
testing.tRunner()
/usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:777 +0x16d
==================
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.