User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Markdown - customisation

Mon Jun 16, 2014 1:02 pm

Just wondering if there are any Markdown gurus out there who know if there are any programs which allow you to customise a markdown document based on tags or similar.

The idea is as follows:

Top of document you list a series of optional tags.
Within the document you have tags around blocks of text.

A program then reads the tags at the top and allows you to disable / enable the blocks of text. Simple, but oh so very useful.

Q: Does anything like that already exist?

Small hint: If it doesn't it should! (and when I get time, it will).

Just want to avoid reinventing something which may already be around.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
duberry
Posts: 379
Joined: Mon Jan 28, 2013 10:44 pm
Location: standing on a planet that's evolving. And revolving at nine hundred miles an hour

Re: Markdown - customisation

Mon Jun 16, 2014 6:19 pm

When you say
disable / enable the blocks of text.


I take it to mean show / hide , is my interpretation correct \ as you meant it ?..

This sound's to me like some kind of mark down 'live' preview
lend me your arms, fast as thunderbolts, for a pillow on my journey.
If the environment was a bank, would it be too big to fail
so long; and thanks for all the pi

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: Markdown - customisation

Mon Jun 16, 2014 8:39 pm

My thinking is to be able to select between different options, by using a program to rebuild the text by selecting various tags (i.e. you would be able to enable a section of text which includes setup information, or remove it if it wasn't needed). This would allow you to generate customised pdfs etc.

I'm thinking like how #define and #ifdef etc work in code to enable/disable sections of test code or functionality based on what is wanted. It doesn't need to be dynamic, just something people are able to customise before using.

I'm fairly sure I can make something work using comments and parsing the files, but wondering if it has been done before, or if there is anything in HTML that does this (so I can pick similar formatting).
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Markdown - customisation

Tue Jun 17, 2014 12:05 pm

Have a look at The General Purpose Preprocessor

Simplest possible example:

Code: Select all

$ cat sample.txt 
This is a header.
Hello there!
#ifdef BASIC
Basic instructions go here.
#endif
#ifdef ADVANCED
Guru instructions follow here...
.
.
.
#endif
This is the footer.

Code: Select all

$ gpp  -DBASIC sample.txt 
This is a header.
Hello there!
Basic instructions go here.
This is the footer.

Code: Select all

$ gpp  -DADVANCED sample.txt 
This is a header.
Hello there!
Guru instructions follow here...
.
.
.
This is the footer.

Code: Select all

$ gpp  -DBASIC -DADVANCED sample.txt 
This is a header.
Hello there!
Basic instructions go here.
Guru instructions follow here...
.
.
.
This is the footer.
--
Ragnar

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: Markdown - customisation

Tue Jun 17, 2014 12:34 pm

Excellent, that will save a lot of leg-work. I may combine it with comments so that it is seamless within markdown.

Many thanks!
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
scruss
Posts: 2348
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Markdown - customisation

Tue Jul 01, 2014 5:08 pm

Markdown is (deliberately) a very small, simple, readable markup language which maps directly to HTML. Any extensions will break it, especially if you have to accept text from other people. There are already hundreds of (very slightly) incompatible forks/variants/standards/etc. All of them are trying to reimplement XML in some small way, and failing.

Write in MD if you want, but as soon as it becomes limiting, use something else. AsciiDoc is more mature than MD, and maps onto DocBook. If you outgrow DocBook, well, good luck to you … To convert between this Tower of Babel of markup formats, Pandoc does the job — including handling markup formats older than I am …
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: Markdown - customisation

Tue Jul 01, 2014 8:54 pm

Yes, that is kind of the problem and its advantage.

I'm only going to break it if I need to, and if I can do it in a way that doesn't impact the use of it. At the moment, I'll avoid doing it.

I'm not overly taken with markdown as a choice for documenting things, particularly when it comes to producing printed material from it. Reminds me too much of wiki format which has just the same issues.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

Return to “Off topic discussion”