Last update: 2024-09-28
python3 -m http.server 8000
The keyboard command Ctrl+C
sends a
SIGINT
You can use the special shell variable $0. This variable holds the name of the script being executed.
# Echo the name of the script
echo "Running script: $0"
This option limits the search depth to the current directory, preventing it from descending into subdirectories.
# Find the latest 10 modified .md files in the current directory only
LATEST_FILES=$(find . -maxdepth 1 -name "*.md" -type f -exec stat -f "%m %N" {} + | sort -nr | head -10 | cut -d' ' -f2-)
#!/bin/bash
# Directory containing the Markdown files
DIR="path/to/your/directory"
# Store the current working directory
CURRENT_DIR=$(pwd)
# Change to the directory containing the Markdown files
cd "$DIR" || exit
# Find the latest 10 modified .md files based on modification time
LATEST_FILES=$(find . -name "*.md" -type f -exec stat -f "%m %N" {} + | sort -nr | head -10 | cut -d' ' -f2-)
# Loop over the files and convert each to HTML
for FILE in $LATEST_FILES; do
# Convert to HTML (using pandoc)
OUTPUT_FILE="${FILE%.md}.html"
# Convert only if the output HTML doesn't exist or the MD file is newer
if [ ! -f "$OUTPUT_FILE" ] || [ "$FILE" -nt "$OUTPUT_FILE" ]; then
pandoc "$FILE" -o "$OUTPUT_FILE"
echo "Converted $FILE to $OUTPUT_FILE"
else
echo "$OUTPUT_FILE is up to date; skipping conversion."
fi
done
# Change back to the original directory
cd "$CURRENT_DIR" || exit
#!/bin/bash
# Directory containing the Markdown files
DIR="path/to/your/directory"
# Find the latest 10 modified .md files based on modification time
LATEST_FILES=$(find "$DIR" -name "*.md" -type f -exec stat -f "%m %N" {} + | sort -nr | head -10 | cut -d' ' -f2-)
# Loop over the files and convert each to HTML
for FILE in $LATEST_FILES; do
# Convert to HTML (using pandoc)
OUTPUT_FILE="${FILE%.md}.html"
# Convert only if the output HTML doesn't exist or the MD file is newer
if [ ! -f "$OUTPUT_FILE" ] || [ "$FILE" -nt "$OUTPUT_FILE" ]; then
pandoc "$FILE" -o "$OUTPUT_FILE"
echo "Converted $FILE to $OUTPUT_FILE"
else
echo "$OUTPUT_FILE is up to date; skipping conversion."
fi
done
chmod +x script.sh
Using partials
as shown in Pandoc docs. Added ${ footer.html() }
at the
end of template.html
as shown below:
${ footer.html() }
</body>
</html>
This simplifies arguments in Obsidian Export Settings, i.e. removed
-A footer.html
:
-f ${fromFormat} --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --lua-filter="${luaDir}/math_block.lua" --standalone --template template.html --bibliography refs.bib --citeproc --csl apa.csl -o "${outputPath}" -t html
-f ${fromFormat} --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --lua-filter="${luaDir}/math_block.lua" --standalone --template template.html -A footer.html --bibliography refs.bib --citeproc --csl apa.csl -o "${outputPath}" -t html
--mathjax="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js"
How to set a default directory when you open a new Terminal window on macOS:1
cd /path/to/your/default/directory; clear
\(\LaTeX\)
\(f(x)=\frac{P(x)}{Q(x)}\:\frac{\frac{1}{x}+\frac{1}{y}}{y-z}\:\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x\)
\(\left\{\begin{array}{cl} {a_{11}x_1+a_{12}x_2+\cdots+a_{1n}x_n=b_1}\\\vdots \\{a_{21}x_1+a_{22}x_2+\cdots+a_{2n}x_n=b_1}\end{array}\right.\)
\[ \sum_{\substack{0\le i\le m\\ 0\lt j\lt n}} P(i,j) \]
\(\texttt{Typewriter}\)
\(\texttt{CONTINUUM}\)
\(\texttt{continuum}\)
\(\mathbb{CONTINUUM}\)
\(\mathbb{Continuum}\)
Pretty good \(\mathbb{LaTeX}\) equation editor.
Based on steps via ChatGPT.↩︎