To ensure that your article is at least 800 words long, covers the key concepts in detail, and is properly formatted, follow these steps:
-
Provide a detailed context topic, covering the key concepts with subtitles (use H2, H3, etc.). Use
<p></p>tags for paragraphs. -
Enclose code blocks with
<code>tags. The content inside code blocks must be properly formatted according to the programming language, including indentation and tabulation needed. Exclude the H1 tag title, which should be provided separately. -
End the article with a summary and references in an HTML unordered list (
<ul>). Specify the types of references included (books, articles, online resources). Do not use page layout tags like<div>,<hr>, etc. Avoid mentioning multipage articles; the purpose is to generate a single page. -
Generate plain HTML output. Ensure the output HTML is valid.
-
To automate this process using a Git hook, you can use the following command:
cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
Then, modify the .git/hooks/pre-commit file as follows:
#!/bin/sh
git diff --cached --diff-index --ignore-space-at-eol --ignore-blank-lines | grep -E '^([A-Za-z0-9\/\-\_]+)\.md$' | while read file; do
cat $file | grep -E '^(#|<h[2-6]>|<p>|<code>|</code>|<ul>|</ul>|<li>|<a>' | wc -l
if [ $(cat $file | grep -E '^(#|<h[2-6]>|<p>|<code>|</code>|<ul>|</ul>|<li>|<a>' | wc -l) -lt 800 ]; then
echo "Error: Article is less than 800 words long."
exit 1
fi
done
exit 0
This script checks the number of lines containing headers (H1-H6), paragraphs (<p>), code blocks (<code>), unordered lists (<ul>), list items (<li>), and links (<a>) in each .md file, and exits with an error if the total is less than 800.