-
Notifications
You must be signed in to change notification settings - Fork 8
Change conversion mechanism to create better markdown files #71
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
06a2e2a
Improve release notes
Akrog 16010ff
Change doc conversion
Akrog 2b71ddf
Fix doc header formatting
Akrog 7be6d8c
Fix non-conformant source docs
Akrog e843bb0
Add AsciiDoc callout handling
Akrog cfda403
Fix AsciiDoc table issues
Akrog e00de6c
Improve/fix logging
Akrog 974322f
Downstream: Fix attributes problem
Akrog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| lightspeed-rag-content @ git+https://github.com/lightspeed-core/rag-content@main | ||
| packaging | ||
| lxml |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| -- fix-codeblock-tables.lua | ||
| -- AI: File generated by Cursor | ||
| -- Ensures code blocks with table-like content maintain proper indentation | ||
| -- | ||
| -- When pandoc converts DocBook to markdown, it sometimes outputs lines starting | ||
| -- with `|` without proper indentation in code blocks. This happens because `|` | ||
| -- is the markdown pipe table delimiter, and pandoc tries not to interfere with it. | ||
| -- This filter fixes the indentation at the AST level before markdown generation. | ||
|
|
||
| function CodeBlock(elem) | ||
| local text = elem.text | ||
| local lines = {} | ||
|
|
||
| -- Split into lines | ||
| for line in text:gmatch("([^\n]*)\n?") do | ||
| if line ~= "" or #lines > 0 then | ||
| table.insert(lines, line) | ||
| end | ||
| end | ||
|
|
||
| -- Check if this looks like a table (has lines with +- borders and | rows) | ||
| local has_table_rows = false | ||
| local has_border = false | ||
|
|
||
| for _, line in ipairs(lines) do | ||
| -- Check for table rows (lines starting with | after optional whitespace) | ||
| if line:match("^%s*|") then | ||
| has_table_rows = true | ||
| end | ||
| -- Check for table borders (lines with +- pattern) | ||
| if line:match("^%s*%+%-") then | ||
| has_border = true | ||
| end | ||
| end | ||
|
|
||
| -- If it's a table-like block, normalize all indentation | ||
| if has_table_rows and has_border then | ||
| -- Find the indentation of border lines (they should have correct indentation) | ||
| local border_indent = "" | ||
| for _, line in ipairs(lines) do | ||
| local indent = line:match("^(%s*)%+%-") | ||
| if indent then | ||
| border_indent = indent | ||
| break | ||
| end | ||
| end | ||
|
|
||
| -- Apply same indentation to all table-related lines | ||
| local fixed_lines = {} | ||
| for _, line in ipairs(lines) do | ||
| local stripped = line:match("^%s*(.*)$") | ||
|
|
||
| -- Check if this is a table-related line | ||
| local is_table_line = stripped:match("^[|+]") or | ||
| stripped == "..." or | ||
| stripped == "…" | ||
|
|
||
| if is_table_line then | ||
| -- Check current indentation | ||
| local current_indent = line:match("^(%s*)") | ||
|
|
||
| -- Only fix if indentation is significantly less than border indent | ||
| if #current_indent < #border_indent - 2 then | ||
| table.insert(fixed_lines, border_indent .. stripped) | ||
| else | ||
| table.insert(fixed_lines, line) | ||
| end | ||
| else | ||
| -- Not a table line, keep as-is | ||
| table.insert(fixed_lines, line) | ||
| end | ||
| end | ||
|
|
||
| elem.text = table.concat(fixed_lines, "\n") | ||
| end | ||
|
|
||
| return elem | ||
| end | ||
|
|
||
| return {{CodeBlock = CodeBlock}} | ||
|
|
||
|
|
||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.