-
-
Notifications
You must be signed in to change notification settings - Fork 362
docs: script to convert HTML manual pages to markdown #4620
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 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cbb2324
docs: script to convert HTML manual pages to markdown
neteler 5972b2f
Merge branch 'main' into manual_html2md
neteler 023f943
HTML: Process the tmp file to selectively replace .html with .md only…
neteler 4d2f822
Merge branch 'main' into manual_html2md
neteler 2076251
Merge branch 'main' into manual_html2md
neteler 7524c52
Merge branch 'main' into manual_html2md
neteler 8ccc15d
added signal handler to cleanup at user break
neteler 80c5ce5
switch to bash
neteler f91a111
un-escape in text (e.g. in grass.html#examples)
neteler df635eb
Merge branch 'main' into manual_html2md
neteler dcf1572
grass_html2md.sh: also convert relative URLs with #anchor but keep fu…
neteler 8f04336
change markdown fenced code blocks from bash to shell
neteler ec845be
Merge branch 'main' into manual_html2md
wenzeslaus 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
############################################################################### | ||
# Convert recursively all .html files to .md (GitHub flavoured Markdown) | ||
# | ||
# Dependencies: | ||
# pandoc | ||
# wget | ||
# | ||
# Author(s): | ||
# Martin Landa, Markus Neteler | ||
# | ||
# Usage: | ||
# If you have "pandoc" in PATH, execute for HTML file conversion in | ||
# current directory and subdirectories: | ||
# ./utils/grass_html2md.sh | ||
# | ||
# COPYRIGHT: (C) 2024 by the GRASS Development Team | ||
# | ||
# This program is free software under the GNU General Public | ||
# License (>=v2). Read the file COPYING that comes with GRASS | ||
# for details. | ||
# | ||
############################################################################### | ||
|
||
# define $TMP if not present | ||
if test -z "${TMP}" ; then | ||
TMP="/tmp" | ||
fi | ||
|
||
# TODO: path to LUA file setting to be improved (./utils/pandoc_codeblock.lua) | ||
#wget https://raw.githubusercontent.com/OSGeo/grass/refs/heads/main/utils/pandoc_codeblock.lua -O "${TMP}/pandoc_codeblock.lua" | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TMP="utils" | ||
petrasovaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# run recursively: HTML to MD | ||
for f in `find . -name *.html`; do | ||
echo "${f}" | ||
cat "${f}" | sed 's#<div class="code"><pre>#<pre><code>#g' | sed 's#</pre></div>#</code></pre>#g' | pandoc \ | ||
--from=html --to=markdown -t gfm --lua-filter "${TMP}/pandoc_codeblock.lua" | \ | ||
sed 's+ $++g' | sed 's+\.html)+\.md)+g' > "${f%%.html}.md" | ||
neteler marked this conversation as resolved.
Show resolved
Hide resolved
neteler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
done |
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,8 @@ | ||
-- Pandoc Lua filter to handle code blocks | ||
-- Test cases | ||
-- raster/r.sun/r.sun.html | ||
|
||
-- Function to convert code blocks to markdown | ||
function CodeBlock (cb) | ||
return pandoc.RawBlock('markdown', '```bash\n' .. cb.text .. '\n```\n') | ||
end |
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.