A Markdown to HTML compiler
No need for Medical Doctors when you have a Doctor of Philosophy on hand - Gangsta Euripides
This tool is currently a Markdown to HTML converter and part of a static blog generator stuffed in one vehicle. I have been meaning to fix this for a long time but haven't gotten around to it just yet. Here are some TODOs:
- write a (E)BNF grammar for the language I’m implementing (rather than an informal listing of features)
- decouple the blog functionality from the Markdown parsing functionality
- corollary: allow Markdown parsing portion to be used as a header library
- better error checking
- tests (pass at least most of John Gruber's Markdown tests)
- use less ad-hoc parsing techniques
- become a UNIX filter program (accept from stdin, write to stdout)
git clone https://github.com/joshnatis/phd
- edit the variables in the
config()
function on top ofphd.cpp
to configure your settings make
- Optional: install
highlight.js
from their page for syntax highlighting in code blocks. If you choose not to install it, make sure to set theUSING_HIGHLIGHT_JS
flag to false inphd.cpp
.
./phd input.md output.html
c++11
and make
- Headings
#
,##
,###
, ...######
- <h1> through <h6>
- Emphasis
**x**
or__x__
for bold*x*
or_x_
for italic~~x~~
forstrikethrough==x==
for highlight++x++
for underline^x^
for superscript~x~
for subscript
- Code blocks
```[optional language] <newline> ... <newline> ```
- automatic syntax highlighting if you link the
highlight.js
script
- Inline code
`This is inline code`
- This surrounds the inline code in
<code>
tags with the classinline-code
. You can add styles for.inline-code
to change how it looks.
- Images

|inline css, e.g. width: 50%; height: 30%|
- Links
[link text](https://url.com)
- <hr> (horizontal rule)
---
- Line breaks
- One or more blank lines between content in the markdown will yield a blank line in the resultant html
- You can freely use
<br>
tags
- Blockquotes
> this is all a blockquote
- Consecutive
>
's with no blank lines between will all be funneled into a single blockquote
- Lists
*
,+
, or-
for bulleted lists,1.
(or any number) for numbered lists- To nest lists, include two spaces or a tab before your bullet point
- Escaped characters
\>
,\&
,\<
,\*
,\_
,\^
,\~
,\`
- Alternate URL syntax
[https://url.com]
,<url.com>
, and/orhttps://url.com
.
- Nesting different types of lists together is buggy
- Nesting lists in general is buggy because I misunderstood how nesting lists in HTML works
- Inline code gets parsed for tags (it should have no formatting)
- <a> tags get parsed for tags (vry bad, this ruins links)
- Everything else (wait... there's not much else)
I didn't use regex, so now I only have 99 problems instead of 2.
I know you want em...
An example blog lives here.