aboutsummaryrefslogtreecommitdiff
path: root/element.go
AgeCommit message (Collapse)Author
2025-02-16all: move setting attribute to DocumentShulhan
Some of attribute may depends on property of the Document.
2024-10-15all: group all image related method and functions into single fileShulhan
This is to make it easy to see how it parsed and how it written to HTML, make the code more searchable. While at it, add test for block image.
2024-09-07all: fix signature of [Element.WriteByte]Shulhan
The WriteByte is the method in that conform [io.ByteWriter].
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: rename meta or metadata words to document attributeShulhan
The idea is to provide consistent naming for metadata and attribute. The AsciiDoctor documentation mostly name them as document attribute.
2024-03-05all: replace if-else bytes.Equals with static string case comparisonsShulhan
2024-03-05all: comply with linter recommendationsShulhan
2024-03-05all: replace module "share" with "pakakeh.go"Shulhan
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-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 (`—` 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
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-11-27all: implement inline macro for passthrough ("pass:")Shulhan
The inline passthrough "pass:" can be used to control the substitutions applied to a run of text. Ref: https://docs.asciidoctor.org/asciidoc/latest/pass/pass-macro/
2022-10-20all: implement macro "footnote:"Shulhan
Macro footnote grammar, ---- "footnote:" [ REF_ID ] "[" STRING "]" ---- In asciidoctor, footnote can be placed anywhere, even after WORD without space in between. The REF_ID, define the unique ID for footnote and can be used to reference the previous footnote. The first footnote with REF_ID, should have the STRING defined. The next footnote with the same REF_ID, should not have the STRING defined; if its defined, the STRING is ignored.
2022-08-06all: rewrite unit tests for inlineParser using test.DataShulhan
Using string literal for testing string input that may contains backtick or double quote make the test code become unreadable and hard to modify. The test.Data help this by moving the input and expected output into a file that can we write as is.
2022-08-05all: cleaning up codesShulhan
Use raw string literal whenever possible.
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: realign all structsShulhan
Minimize struct allocation, * columnFormat: from 40 to 16 bytes (-24 bytes) * document: from 400 to 392 bytes (-8 bytes) * element: from 312 to 264 bytes (-48 bytes) * elementAttribute: from 80 to 72 bytes (-8 bytes) * elementInclude: from 128 to 120 bytes (-8 bytes) * elementTable: from 88 to 64 bytes (-24 bytes) * inlineParser: from 64 to 40 bytes (-24 bytes) Plus all structs in the test files.
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>
2022-02-16all: fix list check box text get cut one characterShulhan
Given the following asciidoc check box markup, * [ ] abc It will rendereded as "&#10063; bc" instead of "&#10063; abc". This commit fix this issue.
2022-02-06all: replace bytes.Title and strings.Title with functionShulhan
Both of those functions has been deprecated. Since the Title function is to convert the adminition string into a human title (first letter uppercase), we can use a function to do that. Any unknown admonition will be returned as is.
2021-12-06all: fix parsing and rendering cross referenceShulhan
Previously, when parsing cross reference we assume that if the string contains upper-case letter then it's a label so we store it as title to search for ID later. The bug is when ID is set manually and its contains upper-case for example "[#Id]". This changes fix this issue by storing cross reference first, not assuming it as ID or title, and then when doing rendering we check whether its ID or title.
2020-12-24all: remove parameter isForToC on method element.toHTMLShulhan
This is to minimize call stack size since the method will be called recursively.
2020-12-24all: move some list ordered class names to constantsShulhan
2020-12-24all: rename type adocTable to elementTableShulhan
2020-12-24all: rename the file adoc_node to elementShulhan