-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heading auto identifier #175
Open
chowette
wants to merge
35
commits into
mity:master
Choose a base branch
from
chowette:heading-auto-identifier
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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 imply scanning and transforming the heading text. As the heading text is transformed, we need to stor it somewhere. Instead of doing almost one malloc for each heading, allocate a large buffer and store all indentifier inside, and using index. We also remember the heading in the header Block to later retrieve it.
Do not hold pointer to reallocated memory. Realloc can copy to a new location and our pointers are now invalid. memorize the offset in the buffer instead, this remain valid even after reallochas relocated the buffer
the block line(s) is always trimed when build
like `ΑΓΩ` is changed to `αγω`
It works but need more work because - bad O(n²) algorithm to be replaced by a hash[Map|Set] - use snprintf for simple int_to_str implementation
Codecov Report
@@ Coverage Diff @@
## master #175 +/- ##
==========================================
+ Coverage 94.32% 94.36% +0.04%
==========================================
Files 3 3
Lines 3100 3496 +396
==========================================
+ Hits 2924 3299 +375
- Misses 176 197 +21
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
ISUNICODEPUNCT_() use a codepoint not an offset. use ISPUNCT_()
some indentation cleaning
Use a pointer and a size instead of begining and ending index. We need a pointer because we want to store the heading identifier as destination, but the identifier is not part of the initial ctx->txt buffer. This is done like the `title` We also cascade change the `MD_LINK_ATTR` struct and supporting functions
so we can reuse it for heading
- depth for toc output - Increase the abi_version to 1 - add --table-of-content option to md2html - add --toc-depth=x to limit TOC levels
--table-of -content option has a parameter to set the mark --toc is a shorthand for the --table-of-content option wrong TOC depth is now an error
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implement an extension when generating heading. This make possible to link directly to heading.
Github, Pandoc and other Markdown libs provide this feature.
Because this is an extension, there is a flag and a command line switch to enable it.
MD_FLAG_HEADINGAUTOID
and corresponding--fheading-auto-id
are addedThis PR is a work in progress and the tasks remaining are:
identifier generation in HTML
identifier transformation like github
-
ΑΓΩ
->αγω
-1
identifier transformation like Pandoc
-
_
and.
, but do not add additional-
for surrounding spaceΑΓΩ
->αγω
-1
section
add a Table of Content
[[_TOC_]]
like RedCarpet MarkdownAdd TOC option to the parser parameter struct for
md_parse()
andmd_html()