Par “conditional comments”

Ir tāda lieta HTMLā kā “conditional comments“, kas ir parasti SGML komentāri, kurus Internet Explorer 5+ tomēr “lasa” un mēģina saprast. Un ja tur atrodas [if kautkas] tad tas tiek ņemts vērā.

Parasti tiek lietots, lai speciāli priekš IE ielādētu papildus CSS failu vai “pielabotu” atsevišķas CSS definīcijas, bet tikpat labi, lūk, arī alternatīvs pielietojums nosacījumam “ja tiek lietots IE”.

<!--[if IE]>
<a href="http://www.getfirefox.com/" title="Browse happy">Go get firefox</a>
<![endif]-->

Word to Markdown converter

Some smart people who didn’t want to teach users how to code in HTML invented Textile markup language

Someone more lazy invented MarkDown syntax which is much easier to learn. MarkDown is really nice for small content management systems, blogging engines etc.

For instance, to mark text as bold, you write the “bold text” like “__bold text__”. Other rules can be found in the syntax page.

However, when you have a MS Word document with several pages of bolds, italics and lists, you don’t really want to re-code all the markup.

This is why I wrote a simple macro for converting the most trivial things automatically. This macro does:

  • Replace bold and italics
  • Replace headings (marked heading1-6)
  • Replace numbered and bulleted lists

It’s very buggy, I believe it hangs on larger documents, however I’m NOT stating it’s a stable release anyway! :-) Experimental use only, recode and reuse it as you like, post a comment if you’ve found a better solution.

Click here to download the code.

To use the code:

  • open WinWord,
  • press Alt+F11 to open the VBA editor,
  • right click the first project in the project browser
  • choose insert->module
  • paste the code from the file
  • close macro editor
  • go tools>macro>macros; run the macro named MarkDown