Commit Graph

51 Commits

Author SHA1 Message Date
Miek Gieben 7898e033b3 html: allow setting the tag for IDs
For the blockattributes it is nice to be able to switch this to
something else.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-23 07:47:27 +02:00
Miek Gieben 9f8ffcf487 matter: use data-matter
Just using matter is not legal in html5, `data-` is.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-20 16:22:20 +02:00
Miek Gieben f5d29afaf9 Update readme and other fixes
Update the README with table footer syntax: fixes #77
Update the README and just point to mmark.nl instead of listing
all mmark syntax elements (again).
Fix multiple classes in headers.
Make header.Special a bool and rename it it IsSpecial.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 13:05:53 +02:00
Miek Gieben 026a971788
Merge pull request #75 from mmarkdown/blockattr-fixes
Fix special section
2018-08-18 11:42:22 +02:00
Miek Gieben a98b0dbeb9 Table: parse table footers
This takes the syntax from kramdown: https://kramdown.gettalong.org/syntax.html#tables
Rename tableHead to tableHeader, and use tableFooter for consistency.

It's not guarded by any parser extension, except parser.Tables

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 11:33:30 +02:00
Miek Gieben 34e94474d8 Fix special section
You can't make up you're own attributes, give special header the class
"special". Adjust all testcases.

<hr>: support block level attributes.

Add more tests for block level attributes.

Fix figure attributes, by re-adding the attribute to the inner block
(table, quote or code block).

Fixes #7

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 11:27:17 +02:00
Miek Gieben 665d356b2f Cross reference: prepend '#'
The link is local (by definition) add '#' to mark it as such.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-17 16:41:25 +02:00
Miek Gieben 079fa8b67b Make index ref look like footnote ref
Make these look like each other for consistency.
Citation can contain links use them to link to the bibliography.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-17 08:57:17 +02:00
Miek Gieben 26c06b95cd index: use idx-N for the ID
Make the ID generation more specific to the index.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-16 17:45:43 +02:00
Miek Gieben 5bcf8f8e5a
Merge pull request #63 from mmarkdown/fix-comments
Fix code comment: new flags are named differently.
2018-08-15 17:24:50 +01:00
Miek Gieben d43e795e3e
Merge pull request #62 from mmarkdown/attributes
Set attributes for block element captionFigure
2018-08-15 17:21:24 +01:00
Miek Gieben 0cbe961e3a and fix typo
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 17:19:10 +01:00
Miek Gieben 0d24865f76 Set attributes for block element captionFigure
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 17:09:35 +01:00
Miek Gieben f70d5ac2bd Fix code comment: new flags are named differently.
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 17:59:07 +02:00
Miek Gieben 744eed10c1 just make it an int
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 16:48:04 +02:00
Miek Gieben a4a196b482 Add uniq ID to indices
To allow linking to indices by giving them an ID; without it an index
can not refer back to the actual index item from main index at the end
of the document.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 16:32:06 +02:00
Miek Gieben 699609b6d8 parser: allow indices
This parsed (!item) as an index, subitems are allowed as well as making
the index primary (by adding another !: (!!item). The HTML output is
non-existent and there is no go in gomarkdown to render an index (left
to a custom renderer)

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-13 19:21:00 +02:00
Miek Gieben f2d8c9a57d html: Allow additional head bytes to be injected
Allows one to add more head tags, mostly scripts usually, to be included
in the <HEAD> section of the generated HTML. This keeps the doc self
contained.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-11 11:04:43 +01:00
Miek Gieben 45707013cb Add callout parsing
Add ast.Callout node that is detected in test and extra utils to parse
it in codeblock.

See https://mmark.nl/post/syntax/#callouts for what they are.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-10 22:03:41 +01:00
Miek Gieben 543ba837f9 Make a String() function for AlignmentFlags
Implement the TODO and a method `String()` that returns a string for
AlignmentFlags.

Pondered doing the same for Matters and CitationTypes, but those are
more renderer dependent (and not standard).

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-07 07:43:02 +01:00
Miek Gieben 7e6b680d17 Fix how classes are returned in block level attributes
Also export it, so it can be used directly in mmark/xml/renderer.go (I
had the exact copy of this code there)

Fixes #27

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-06 23:03:09 +01:00
Miek Gieben 6f77bf5ca9 Add citationss
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 17:13:36 +01:00
Miek Gieben 864377cdbf More citations
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 14:27:02 +01:00
Miek Gieben 4128e40d11 correct type
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 08:20:36 +01:00
Miek Gieben bf6ad50793 more
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 08:18:27 +01:00
Miek Gieben 4c3e11dbb9 Fix code block captions
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-02 09:28:41 +00:00
Miek Gieben 950348d1d2 Better
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-02 08:03:58 +01:00
Miek Gieben 77587eb931 Support captions
This adds Mmark support for captions under quotes block or fenced code
blocks. This can be used by adding: `Caption: <text>` under the block.
All text up to the next empty line is read.

This adds ast.Caption, which is a noop in the html/renderer because the
elements need to walk this node outside of the main ast. The node can
only hold span elements (p.inline()).

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-01 19:21:35 +01:00
Miek Gieben 055b0aac3f Add document divisions
Signed-off-by: Miek Gieben <miek@miek.nl>

Implement document divisions

front/main/back-matter. There is no html equivalent of these.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-01 13:46:33 +00:00
Miek Gieben f1700b7c88 WIP: Mmark: implement asides
This implements asides, blockquote like paragraph prexifed with `A>`
instead of just a '>'

Adds the extension MmarkAsides

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 22:23:27 +01:00
Miek Gieben f45815586d Mmark: add SpecialHeading
This adds detection for headers that start with `.#`. It adds the Mmark
extension, update the mmar test, adds some documentation.

I'm reusing the ast.Heading to have a maximum amount of code re-use.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 22:09:19 +01:00
Miek Gieben 0355745bf4 Ordered list: detect starting number
This keeps track of the starting number of an ordered list and uses it
when not zero. Fails the tests so it will probably have to wait until
we have the Mmark extension merged.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 09:09:41 +01:00
Miek Gieben afb306b9ee remove newline
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 08:42:38 +01:00
Miek Gieben aebf1c6233 Add block attributes
This adds the possibility to add block level attributes:

    {#id2}
    > line

When enabled to will generate (for HTML) an id="id2" in the openening
tag of the block quote:

    <blockquote id="id2">
    <p>line</p>
    </blockquote>

Only one block level attribute is allowed, if multiple are given only
the last one seen is applied, the rest is silently ignored.

The attributes are stored in *Parser and copied to the node in addBlock.
It's up to the renderer to use the attributes, the html renderer
currently applies them to most block level elements.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 08:42:38 +01:00
Krzysztof Kowalczyk 9bd36d810e add MathJax support; fixes #4 2018-04-15 23:34:22 -07:00
Krzysztof Kowalczyk 2e45a08a2a make tests work on windows by normalizing newlines 2018-04-15 22:26:04 -07:00
Krzysztof Kowalczyk 9a8d41a7c5 improve comments 2018-03-15 13:11:31 -07:00
Krzysztof Kowalczyk 7c15bc5850 remove rel='footnote' which is not valid in html5 2018-02-26 01:14:35 -08:00
Krzysztof Kowalczyk e6baec3497 remove PanicIfContainer; it was incorrectly implemented and incorrectly used 2018-02-01 13:08:59 -08:00
Krzysztof Kowalczyk c1390b0a06 rename LastChild() => GetLastChild() etc. 2018-01-31 01:02:27 -08:00
Krzysztof Kowalczyk 724ca64990 simplify implementation of Walk(); make LastChild(), FirstChild() stand-alone functions 2018-01-28 15:06:21 -08:00
Krzysztof Kowalczyk 35f86d5571 rename TreeNode => Container and LeafNode => Leaf 2018-01-28 05:13:46 -08:00
Krzysztof Kowalczyk 3449e2a1bf style tweaks 2018-01-28 04:51:37 -08:00
Krzysztof Kowalczyk 363d20a3a0 tweak style 2018-01-28 04:46:09 -08:00
Krzysztof Kowalczyk d4a12c3518 better names 2018-01-28 02:46:13 -08:00
Krzysztof Kowalczyk a63ba13b3a improve names 2018-01-28 02:38:32 -08:00
Krzysztof Kowalczyk e7a0f55d02 update names 2018-01-28 02:22:50 -08:00
Krzysztof Kowalczyk 242d66580e complete refactor 2018-01-28 00:50:21 -08:00
Krzysztof Kowalczyk 84fa04bf9d less boilerplate 2018-01-27 20:51:43 -08:00
Krzysztof Kowalczyk 13e3bc6dd2 rename params => opts 2018-01-27 18:40:11 -08:00