Skip to content

Instantly share code, notes, and snippets.

@maskshell
Forked from cheungnj/script.sh
Created July 20, 2022 03:25
Show Gist options
  • Select an option

  • Save maskshell/f65aefd04d0f3bebd7eeb78d612517be to your computer and use it in GitHub Desktop.

Select an option

Save maskshell/f65aefd04d0f3bebd7eeb78d612517be to your computer and use it in GitHub Desktop.

Revisions

  1. @cheungnj cheungnj revised this gist Oct 31, 2017. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,8 @@ $ pandoc -f docbook -t gfm foo.xml -o foo.md

    $ iconv -t utf-8 foo.xml | pandoc -f docbook -t gfm | iconv -f utf-8 > foo.md

    # Pandoc inserted hard line breaks at 80 characters. Removed like so:
    # Pandoc inserted hard line breaks at 72 characters. Removed like so:

    $ iconv -t utf-8 foo.xml | pandoc -f docbook -t gfm --wrap=none | iconv -f utf-8 > foo.md
    $ pandoc -f docbook -t gfm --wrap=none # don't wrap lines at all

    $ pandoc -f docbook -t gfm --columns=120 # extend line breaks to 120
  2. @cheungnj cheungnj revised this gist Oct 31, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Adapted from https://tinyapps.org/blog/nix/201701240700_convert_asciidoc_to_markdown.html
    # Using asciidoctor and pandoc 2.0.0.1
    # Install pandoc and asciidoc
    # Using asciidoctor 1.5.6.1 and pandoc 2.0.0.1
    # Install pandoc and asciidoctor

    $ sudo apt install asciidoctor
    $ sudo wget https://github.com/jgm/pandoc/releases/download/2.0.0.1/pandoc-2.0.0.1-1-amd64.deb
  3. @cheungnj cheungnj renamed this gist Oct 31, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @cheungnj cheungnj created this gist Oct 31, 2017.
    25 changes: 25 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Adapted from https://tinyapps.org/blog/nix/201701240700_convert_asciidoc_to_markdown.html
    # Using asciidoctor and pandoc 2.0.0.1
    # Install pandoc and asciidoc

    $ sudo apt install asciidoctor
    $ sudo wget https://github.com/jgm/pandoc/releases/download/2.0.0.1/pandoc-2.0.0.1-1-amd64.deb
    $ sudo dpkg -i pandoc-2.0.0.1-1-amd64.deb

    # Convert asciidoc to docbook using asciidoctor

    $ asciidoctor -b docbook foo.adoc

    # foo.xml will be output into the same directory as foo.adoc

    # Convert docbook to markdown

    $ pandoc -f docbook -t gfm foo.xml -o foo.md

    # Unicode symbols were mangled in foo.md. Quick workaround:

    $ iconv -t utf-8 foo.xml | pandoc -f docbook -t gfm | iconv -f utf-8 > foo.md

    # Pandoc inserted hard line breaks at 80 characters. Removed like so:

    $ iconv -t utf-8 foo.xml | pandoc -f docbook -t gfm --wrap=none | iconv -f utf-8 > foo.md