Linux script to convert Markdown files from JupyterLab format to Qiita format

Overview

Formula code in JupyterLab format$$ $$To```mathConvert to specifications

#script

run.sh


filename=${1-'code.md'}

 search $$
nl -ba $filename | grep "\$\\$" > TMP

 num of iteration
nrow=(`wc TMP    | awk '{print $1}'`)

 get row number
array=($(cat TMP | awk '{print $1}'))

for i in `seq 1 ${nrow}`
do

  echo ${array[$((i-1))]}

  if [ $(( ${i} % 2 )) == 1 ]
  then sed -ie "${array[$((i-1))]} s/\$\\$/\`\`\`math/g" $filename
  else sed -ie "${array[$((i-1))]} s/\$\\$/\`\`\`/g"     $filename
  fi

done

rm TMP

#Example of use

./run.sh code.md

Recommended Posts

Linux script to convert Markdown files from JupyterLab format to Qiita format
How to easily convert format from Markdown
Convert from Markdown to HTML in Python
I made a script in python to convert .md files to Scrapbox format
Easy script migration from CentOS to Oracle Linux
Convert Qiita articles to Jekyll post format for backup
Copy files directly from Amazon EC2 (Amazon linux) to S3
Convert translation resource files (.po) to XLIFF format (.xlf)
[Linux] Copy data from Linux to Windows with a shell script
[Linux] Compress folders and transfer files from remote to local
[Caffe] Convert mean file from binary proto format to npy format
Script to convert between Xcode language files and tab-delimited text
Convert PIL format images read from form with Django to base64 format
Convert from pdf to txt 2 [pyocr]
How to convert from .mgz to .nii.gz
Convert xml format data to txt format data (yolov3)
Markdown to get Jupyter notebook results to Qiita
[Linux] Flow from power-on to PC startup
Script to generate directory from json file
Convert matplotlib graphs to emf file format
Convert from PDF to CSV with pdfplumber
Convert from katakana to vowel kana [python]
Rename YYYYMMDD format files to serial numbers
[linux] Split files to the specified size
Convert PDF attached to email to text format
How to operate Linux from the console
Convert PDF files to PNG files with GIMP
Convert Python date types to RFC822 format
Convert HEIC files to PNG files with Python
Introducing Docker Engine to Linux From Scratch
How to convert DateTimeField format in Django
How to find large files on Linux
[Amazon Linux] Switching from Python 2 series to Python 3 series