Have the same README both in Markdown and reStructuredText

后端 未结 8 1266
旧时难觅i
旧时难觅i 2020-12-22 16:29

I have a project hosted on GitHub. For this I have written my README using the Markdown syntax in order to have it nicely formatted on GitHub.

As my project is in Py

8条回答
  •  伪装坚强ぢ
    2020-12-22 17:01

    I ran into this problem and solved it with the two following bash scripts.

    Note that I have LaTeX bundled into my Markdown.

    #!/usr/bin/env bash
    
    if [ $# -lt 1 ]; then
      echo "$0 file.md"
      exit;
    fi
    
    filename=$(basename "$1")
    extension="${filename##*.}"
    filename="${filename%.*}"
    
    if [ "$extension" = "md" ]; then
      rst=".rst"
      pandoc $1 -o $filename$rst
    fi
    

    Its also useful to convert to html. md2html:

    #!/usr/bin/env bash
    
    if [ $# -lt 1 ]; then
      echo "$0 file.md "
      exit;
    fi
    
    filename=$(basename "$1")
    extension="${filename##*.}"
    filename="${filename%.*}"
    
    if [ "$extension" = "md" ]; then
      html=".html"
      if [ -z $2 ]; then
        # if no css
        pandoc -s -S --mathjax --highlight-style pygments $1 -o $filename$html
      else
        pandoc -s -S --mathjax --highlight-style pygments -c $2 $1 -o $filename$html
      fi
    fi
    

    I hope that helps

提交回复
热议问题