aboutsummaryrefslogtreecommitdiff
path: root/document_parser.go
AgeCommit message (Collapse)Author
11 daysall: fix parsing literal paragraphShulhan
A line that start with one or more space will be considered as literal paragraph. Once literal line found it will end until an empty line.
2025-04-18all: support include directive inside block codeShulhan
Example of block code with include directive, ---- ... include::file[] ... ----
2025-02-16all: move setting attribute to DocumentShulhan
Some of attribute may depends on property of the Document.
2025-01-21all: fix section detected as paragraph after list and commentShulhan
Previously, given the following markup, ---- * Sub list + Sub list content. //}}} //{{{ == Sub 2 //}} ---- The section "Sub 2" will be parsed as paragraph instead of new section.
2024-08-16all: remove unnecessary TrimRightShulhan
Each lines to be parsed has been trimmed on the first load, so there is no need to do it again, on some cases.
2024-08-16all: support document attribute "leveloffset"Shulhan
The ":leveloffset:" on document attribute allow increment or decrement the heading level on included files. Reference: https://docs.asciidoctor.org/asciidoc/latest/directives/include-with-leveloffset/
2024-08-13all: refactoring DocumentAttribute into structShulhan
Using struct limit the value to only string, while some attributes can be an integer value, for example "leveloffset".
2024-08-13all: add element kind Section 0Shulhan
The elKindSection0 is the Document Title, the line that start with "= ".
2024-08-12all: use strict document header formatShulhan
Previously, an empty line before Document Title cause the parser stop parsing the document header, now an empty lines are skipped. Also document attribute can be place anywhere, either before or after title, and in between attributes; now it can be only placed after revision or author or title.
2024-03-05all: replace module "share" with "pakakeh.go"Shulhan
2023-12-10all: remove dependency to "github.com/shuLhan/share/lib/debug"Shulhan
2023-12-10all: fix custom IDs on first section got replacedShulhan
Any custom ID on the first section always replaced with the subsection because, first, when detecting preamble we did not check for line with kind ID "[[...]]" an short ID "[#...]". Second, when parsing preamble we did not stop when we found line kind ID and short ID. This preamble thing is kind of annoying. We need to revisit again how to detect preamble, maybe not calling separate block parser, but making it linear as the default first child of parent element.
2023-12-09all: replace linter golangci-lint with revive and shadowShulhan
The golangci-lint does not output any results anymore Either we are getting good at writing Go or the linter itself is become less good. We also have seen that the latest golangci-lint is failed to build with Go tip, a simple "make" on the golangci-lint never success in my experiences. This changes fix all the output reported by the revive and shadow.
2023-05-30all: handle custom marker in between unordered listShulhan
Given the following markup, [square] * item 1 [circle] ** item 2 The list on item 2 now start with `<div class="ulist circle">`.
2023-05-28all: add support for unordered list with '-'Shulhan
The unordered list item with hyphen ('-') cause too much confusion and inconsistency, nevertheless most of still use it. Case one, given the following markup, ``` - Item 1 + "A line of quote" -- Author ``` Is the "Author" the sub item in list or we are parsing author of quote paragraph? Case two, the writer want to write em dash (`&#8212;` in HTML Unicode) but somehow the editor wrap it and start in new line. As a reminder, the official documentation only recommend using hyphen for simple list item [1]. [1] https://docs.asciidoctor.org/asciidoc/latest/lists/unordered/#basic-unordered-list
2023-03-02all: handle empty preambleShulhan
If the document contains empty preamble do not output the HTML wrapper of it.
2022-12-19all: support multi line attribute valuesShulhan
If the attribute value end with backslash '\', the value continue to the next line.
2022-12-19all: trim right spaces on each lines before parsingShulhan
This is to minimize checking for space when parsing later.
2022-12-16all: detach parsing preamble from contentShulhan
This is to prevent empty preamble being rendered in HTML content.
2022-12-14all: store the list item counter inside elementShulhan
In the parseListOrdered, each time we found list item, we store its counter and increment it by one so backend can use it to render the counter.
2022-09-05all: fix parsing list description inside include directiveShulhan
Previously, given the following include statements in the main document include::list_desc.adoc[] include::list_desc.adoc[] Where list_desc.adoc content is, Item 00:: + -- * Bullet 0 + Description 0. * Bullet 1 -- The first include is parsed correctly, but the second include is parsed as is.
2022-08-05all: cleaning up codesShulhan
Use raw string literal whenever possible.
2022-07-17all: move Parse and parse functions to documentShulhan
Since the Parse return a *Document it should grouped into document.go to make the code consistent.
2022-07-17all: make the parseHeader state clearShulhan
The state should store the previous kind of line being parsed, not the next state.
2022-07-17all: add element preamble into DocumentShulhan
This is to allow testing the preamble inside the document.
2022-07-16all: reformat all Go filesShulhan
Replace any usage of ":=" with "var" declaration with type. The ideas is to make the code reader know what is the expected return value of function/method.
2022-07-16all: reformat all Go filesShulhan
2022-02-21all: relicense the asciidoctor-go under GPL 3.0 or laterShulhan
Signed-off-by: Shulhan <ms@kilabit.info>
2020-12-26document_parser: remove unused debug statementShulhan
2020-12-24all: rename adocNode to elementShulhan
Using prefix adoc to module asciidoc is kinda bit stutter.
2020-12-20all: do not wrap document with content and preamble on ToEmbeddedHTMLShulhan
Previously, HTMl document generated from ToEmbeddedHTML contains div with id "content" and sub div "preamble". This changes, make the ToEmbeddedHTML generate the HTML document without those divs wrapper.
2020-12-20all: fix parsing list with open blockShulhan
If the list body contains continuation with open block, the whole open block content should be treatent as sub-of block until it end with "--".
2020-12-13document_parser: fix parsing open block inside list itemShulhan
By using open block "--" we allow the list body content without adding "+" for each empty line.
2020-12-10all: refactoring document parser to split content by linesShulhan
Previously, we read the raw content line by line. Unfortunately, this technique did not work for "include" directive, where the included file's content will be embedded to current content. This changes split the initial raw content by lines to make it allow injecting another lines when including directives exist.
2020-12-10all: preparing implementation for "include" directiveShulhan
There are basic things that need to be done before we can implement the "include" directive, especially on how to embed the content of included file into the content of current document.
2020-12-10document: store the full path of parsed file on DocumentShulhan
The full path will be required later for implementing the "include" directive.
2020-12-08all: add support for checklist in unordered listShulhan
2020-12-08all: support custom markers on unordered listShulhan
Custom markers including "square", "circle", "disc", "none", "no-bullet", "unstyled", and any strings that is not part of asciidoc internal styles.
2020-12-03all: remove unused methods and unexport internal methodsShulhan
2020-12-03all: unified the document node attributesShulhan
2020-11-30all: implement table options "footer"Shulhan
2020-11-29all: implement table options "header" and "noheader"Shulhan
2020-11-24chore: increase the debug value to supress logs on DEBUG=1Shulhan
2020-11-24all: support all column style "a", "e", "h", "l", "m", "d", "s", "v"Shulhan
2020-11-23all: implement parser for tableShulhan
Currently supported format with "cols" options are, * setting number of columns, * setting the horizontal and vertical alignment * setting the column width
2020-11-16all: change attributeClass from map to sliceShulhan
Using map is unpredictable for class. Imagine if we have CSS that set style based on order of class "a.b", using map sometimes will generate a string "b a" which will not what we expect.
2020-11-16all: support section "[discrete]" headings styleShulhan
2020-11-15all: implement additional metadatasShulhan
The following metadata has been implemented, * "idprefix": changing the auto generated ID prefix * "idseparator": changing the separator for auto generated ID * "sectids": enabling or disabling auto generated ID * "sectlinks": generate link on section title * "sectanchors: generate an anchor, empty link, before section title
2020-11-15all: unpack the revision number, date, and remark into RevisionShulhan
Also support setting and checking metadata revnumber, revdate, revremark, and version-label.
2020-11-15all: add support for multiple authors with emailShulhan