Description
I present to your attention the extension of the "human" Markdown markup language for use on Habré. The main goals are:
- Replace “human-readable”, but not “human-written” HTML by Markdown.
- Provide support for extended habr markup.
- Automate downloading images and inserting their URL into the article.
- Add syntax highlighting.
Using
- Download and unpack the archive into a separate folder
- Writing an article in the article.txt file
- We copy in the folder the necessary images
- We type
make copy
, we get the HTML text of the article in the article.html file and in the clipboard - We post on habr
Kit contents
- habraml.py - Markdown to HTML extended markup converter.
- Makefile - commands for creating HTML, loading images and other things.
- article.txt is the text of this article as an example.
Requirements
- python-markdown
- python-pygments
- photo-upload
- xsel
- make
Make targets
make
- upload images and generate HTMLmake upload-images
- upload images to imageshack.usmake copy
- upload images, generate and copy HTML to the clipboard
Download
habraml.zipStandard Markdown Markup
Official syntax documentationHeadlines
First level heading
========================
# Too first level heading #
# Or so
Second level heading
------------------------
## Too second
### Third
Text selection
plain text
* oblique, _ also oblique_,
** fat **, __ fat too, __,
`code`
plain text,
oblique ,
also oblique ,
bold ,
also bold ,
Quote
> Familiar-these are people, just in case they call you a fool.
> Good friends can already tell you a bad joke.
> Friends are those who really know a few real nasty things about you.
> Don Aminado
Familiar - these are people, just in case they call you a fool. Good friends can already tell you a bad joke. Friends are those who really know a few real nasty things about you. Don Aminado
Or so:
> The idea, perhaps, has the greater independent value,
the less one believes in her from whom she emanates, for she then does not
reflects his desires, needs and prejudices ...
Oscar wilde
The idea, perhaps, has that greater independent value, the less the one from whom it comes from believes in it, for it then does not reflect its desires, needs and prejudices ... Oscar Wilde
Links
[link to habrahabr] (http://habrahabr.ru)
link to habrahabrList
Unnumbered (you can use "-", "+" and "*"):
- item1
- item2
Numbered (you can use one number for all elements):
1. First
2. Second
- First
- Second
Horizontal bar
--------------------------
Picture
! [Habr logo] (https://habrastorage.org/getpro/habr/post_images/142/895/3aa/1428953aa0d7b50586df81c2bbf78b53.gif)

Extended formatting
Headlines
Header levels are shifted by 3, as required by Habr. Those. headlines start at level four.
Habrakat
-x ----------------------------
-x ---- Text instead of "Read more"
Habrayuser link
@kriomant
kriomantStrikethrough
~~ strikeout text ~~
strikethrough textLocal Images
If the address of the image does not begin with "http: //", then the image is considered local. In this case, two lines are read from the file “address_image.address”: the first is the address of the thumbnail, the second is the address of the full-size image viewing page. A small copy of the image is inserted into the page code with reference to the original. The files “* .address” are automatically generated by the build script when loading images.
Syntax highlighting
@ python @
print ('string')
for item in (2, 3, 4):
print (item)
turns into:
print ( 'string' )
for item in ( 2 , 3 , 4 ):
print (item)
Display problems
The habr parser is a very strange and unpredictable thing. For some reason, he cuts out the “p” tags, does not display “hr”,
incorrect parsing of the link, and even
makes exclamation marks himself . The most necessary hacks, without which nothing is shown at all, I applied. I consider the code to be corrected further under various glitches wrong: the parser may be corrected in a year or two, but no one will redo the text of the article anymore.