Text Markup languages

Please compose all posts in Emacs.

Moderators: phlip, Moderators General, Prelates

Text Markup languages

Postby 0xBADFEED » Sun Dec 14, 2008 9:31 pm UTC

I'm wondering what everyone's favorite text markup language is (e.g. BBCode, Markdown, etc.) and why it is superior to all the other options.

Edit:

Specifically, I mean for controlling text presentation as HTML where it's unwise to allow straight HTML.

Sorry I didn't make that clear.
Last edited by 0xBADFEED on Sun Dec 14, 2008 11:55 pm UTC, edited 2 times in total.
0xBADFEED
 
Posts: 687
Joined: Mon May 05, 2008 2:14 am UTC

Re: Text Markup languages

Postby MoD » Sun Dec 14, 2008 10:53 pm UTC

Real programmers use plaintext. Parentheses work for math, if you're including that in the category of markup languages.
Last edited by MoD on Thu Jan 22, 2009 12:25 am UTC, edited 1 time in total.
User avatar
MoD
 
Posts: 107
Joined: Sun Dec 30, 2007 4:55 pm UTC

Re: Text Markup languages

Postby hotaru » Mon Dec 15, 2008 2:20 am UTC

MoD wrote:Real programmers use plaintext. Parentheses work for math, if you're including that in the category of markup languages.

i agree with this, but there are a few rare cases where markup is useful. for those cases i prefer troff, but xml-based markup is unfortunately becoming more and more common.
Code: Select all
#include <stdio.h>

int main()
{
 struct { unsigned a:3, b:3, c:2; } n = {0};
  do do printf("%hhu\n", *&n);
  while(!(n.a-- && !++n.b));
  while(++n.c);
  return 0; } 
User avatar
hotaru
 
Posts: 931
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: Text Markup languages

Postby ash.gti » Mon Dec 15, 2008 5:39 am UTC

HAML or Redcloth (specifically textile) here

Although for non-html, I stick to plain text and YAML (when I need structure I use YAML because most of the stuff I write ends up being parsed by something at some point or another)
# drinks WAY to much espresso
User avatar
ash.gti
 
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Text Markup languages

Postby Xanthir » Wed Dec 17, 2008 12:21 am UTC

What's wrong with straight html? They make sanitizers for a reason.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))
User avatar
Xanthir
My HERO!!!
 
Posts: 3993
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex

Re: Text Markup languages

Postby ash.gti » Wed Dec 17, 2008 7:31 am UTC

Most markups are designed to shorten the amount you have to write. Keeping it DRY is good.

One of the reasons I like haml is because of its well-formedness, and its nearly xhtml but more DRY.
# drinks WAY to much espresso
User avatar
ash.gti
 
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Text Markup languages

Postby OOPMan » Wed Dec 17, 2008 10:59 am UTC

XML is the Greater Demon and Java is it's master, The Devil.

However...

Sometimes writing an XML Schema and using XMLBeans to generate code which can read XML Documents that are valid instance of said Schema is useful if you need to be able to enforce data structure and composition with minimal effort beyond writing a Schema.
Image

Image
User avatar
OOPMan
 
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: Text Markup languages

Postby Iv » Wed Dec 17, 2008 12:37 pm UTC

MoD wrote:Real programmers use plaintext. Parentheses work for math, if you're including that in the category of markup languages.

I agree and would add that a real programmer has little concern about the specific format used. If it is correctly formatted, conversion should not be hard between what the real life gives you and your ideal solution that will probably only be used as an internal representation (N3 FTW!).
Iv
 
Posts: 1192
Joined: Thu Sep 13, 2007 1:08 pm UTC
Location: Lyon, France

Re: Text Markup languages

Postby 0xBADFEED » Wed Dec 17, 2008 2:40 pm UTC

Real programmers don't start statements with "Real programmers ..."

Seriously though, I don't really have any particular use for it at the moment. There are just so many I was wondering what people's opinions of them are.
0xBADFEED
 
Posts: 687
Joined: Mon May 05, 2008 2:14 am UTC

Re: Text Markup languages

Postby ash.gti » Wed Dec 17, 2008 3:22 pm UTC

OOPMan wrote:XML is the Greater Demon and Java is it's master, The Devil


Have you ever used yaml? There are a bunch of yaml => xml converters, and honestly yaml is a lot easier to understand.

haml can produce valid xml too which is nice.
# drinks WAY to much espresso
User avatar
ash.gti
 
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Text Markup languages

Postby scarecrovv » Wed Dec 17, 2008 6:10 pm UTC

If I don't care about making it look pretty, I use plain text. If I do (which isn't too often) I opt for La\TeX (unfortunately, the forum can't do better than bits of \TeX).
User avatar
scarecrovv
 
Posts: 583
Joined: Wed Jul 30, 2008 4:09 pm UTC
Location: Massachusetts

Re: Text Markup languages

Postby Emu* » Wed Dec 17, 2008 6:13 pm UTC

scarecrovv wrote:If I don't care about making it look pretty, I use plain text. If I do (which isn't too often) I opt for La\TeX (unfortunately, the forum can't do better than bits of \TeX).



Personally I aim for substance over style, but that's up to you...
Cosmologicon wrote:Emu* implemented a naive east-first strategy and ran it for an hour, producing results that rivaled many sophisticated strategies, visiting 614 cells. For this, Emu* is awarded Best Deterministic Algorithm!
User avatar
Emu*
 
Posts: 689
Joined: Mon Apr 28, 2008 9:47 am UTC
Location: Cardiff, UK

Re: Text Markup languages

Postby ash.gti » Wed Dec 17, 2008 9:20 pm UTC

Here are a few working examples of what I am referring too.

html for reference:
Code: Select all
<div id="hello" style="color:black;">
  <h2 style="color:green;">This is a title</h2>

  <h3 class="a_class">This is a subhead</h3>

  <p style="color:red;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ornare aliquam erat. Donec eu risus at urna vehicula interdum. Proin sodales ligula adipiscing mauris. Suspendisse lectus leo, fermentum nec, tempus eget, rutrum quis, eros. <a href="http://www.textism.com" title="optional title">This is a link</a></p>

  <table style="border:1px solid black;">
    <tr>
      <th>this</th>
      <th>is</th>
      <th>a</th>
      <th>header</th>
    </tr>
    <tr style="background:gray;text-align:left;">
      <td colspan="2">this is</td>
      <td style="background:red;width:200px;">a</td>
      <td style="vertical-align:top;height:200px;text-align:justify;">row</td>
    </tr>
    <tr>
      <td>this</td>
      <td style="padding:10px;text-align:justify;">is</td>
      <td style="vertical-align:top;">another</td>
      <td class="bob" id="bob">row</td>
    </tr>
  </table>

  <p><img src="/common/textist.gif" title="optional alt text" alt="optional alt text" /></p>
</div>


Textile: (textile doesn't have a shorthand for <div>)
Code: Select all
<div id="hello" style="color:black;">
h2{color:green}. This is a title

h3(a_class). This is a subhead

p{color:red}. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ornare aliquam erat. Donec eu risus at urna vehicula interdum. Proin sodales ligula adipiscing mauris. Suspendisse lectus leo, fermentum nec, tempus eget, rutrum quis, eros. "This is a link (optional title)":http://www.textism.com

table{border:1px solid black}.
|_. this|_. is|_. a|_. header|
<{background:gray}. |\2. this is|{background:red;width:200px}. a|^<>{height:200px}. row|
|this|<>{padding:10px}. is|^. another|(bob#bob). row|

!/common/textist.gif(optional alt text)!
</div>


haml:
Code: Select all
.hello{:color => "black"}
  %h2{:color => "green"} This is a title

  %h3.a_class This is a subhead

  %p{:color => "red"}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ornare aliquam erat. Donec eu risus at urna vehicula interdum. Proin sodales ligula adipiscing mauris. Suspendisse lectus leo, fermentum nec, tempus eget, rutrum quis, eros.
    %a{:href => "http://www.textism.com", :title => "optional title"}
      This is a link

  %table{:style => "border: 1px solid black"}
    %tr
      %th this
      %th is
      %th a
      %th header
    %tr{:style => "background:gray"
      %td{:colspan => 2} this is
      %td{:style => "background:red;width:200px"} a
      %td{:style => "vertical-align:top;height:200px;text-align:justify;"} row
    %tr
      %td this
      %td{:style => "padding:10px;text-align: justify"} is
      %td{:style => "vertical-align:top"} another
      %td.bob#bob row

  %p
    %img{:src => "/common/textist.gif", :title => "optional alt text"}


Nice thing about haml is the code it spits out is always nice and readable (unless you specify ugly code, which removes whitespace) and you have the full power of ruby for mixing in your code.

I personally, like textile for short snippets, but once you have any sort of complicated (xhtml|xml|html) structure haml is what I go to.

If I am doing structure data I use yaml, heres an example of that:
Code: Select all
# Comments go here
---
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments: >
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.
...


and the XML it represents:
Code: Select all
<invoice xmlns:yaml="http://yaml.org/xml">
   <number>34843</number>
   <date>2001-01-03</date>
   <bill-to yaml:anchor="id001">
      <given>Chris</given>
      <family>Dumars</family>
      <address>
        <lines>458 Walkman Dr.
 Suite #292
 </lines>
        <city>Royal Oak</city>
        <state>MI</state>
        <postal>48046</postal>
      </address>
   </bill-to>
   <ship-to yaml:alias="id001" />
   <product>
      <_>
        <sku>BL394D</sku>
        <quantity>4</quantity>
        <description>Basketball</description>
        <price>450.00</price>
      </_>
      <_>
        <sku>BL4438</sku>
        <quantity>1</quantity>
        <description>Super Hoop</description>
        <price>2392.00</price>
      </_>
   </product>
   <tax>251.42</tax>
   <total>4443.52</total>
   <comments>Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338
</comments>
</invoice>


The yaml is way more readable for me.
# drinks WAY to much espresso
User avatar
ash.gti
 
Posts: 404
Joined: Thu Feb 07, 2008 1:18 am UTC
Location: Probably a coffee shop.

Re: Text Markup languages

Postby Xanthir » Thu Dec 18, 2008 3:22 am UTC

If I'm *not* using html, I like Markdown, personally. Designed to look like plain-text, but turns into html in a well-defined way.

(And for structured data, sexprs!)

Edit: Since this thread reminded me of it, I took the time today to implement a Markdown-based system for my company's FAQ system, which is written by ordinary tech-support folks who only know as much HTML as I force them to learn to write FAQs. It was an immediate hit.

For reference, let's go with Ash.gti's html from the post above me. I'll add a bit, since he doesn't have, say, a list. In Markdown, you'd write it like this:
Code: Select all
# This is a title

## This is a subhead

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ornare aliquam erat. Donec eu risus at urna vehicula interdum. Proin sodales ligula adipiscing mauris. Suspendisse lectus leo, fermentum nec, tempus eget, rutrum quis, eros.  [This is a link](http://daringfireball.net/projects/markdown/)

[Here's another link][link2]

|this|is|a      |header|
|====|==|=======|======|
|this|is|a      |row   |
|this|is|another|row   |

* unordered list item 1
* ul 2
* ul 3

1. ol 1
2. ol 2
3. ol 3

![optional alt text](http://daringfireball.net/graphics/logos/ "optional title text")

[link2]: http://www.example.com
         "An example link"

Yeah, it loses some features. It's not meant to capture all of html. It's meant to be a simple way to write out simple html, in a way that is completely human readable. Markdown'd text is pretty much exactly how you would format an ordinary plain-text message. This makes it trivial to learn, and frankly, fun to write.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))
User avatar
Xanthir
My HERO!!!
 
Posts: 3993
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex

Re: Text Markup languages

Postby phillipsjk » Sun Dec 21, 2008 6:46 pm UTC

Xanthir wrote:What's wrong with straight html? They make sanitizers for a reason.


Have you TRIED to use standard-compliant HTML on Myspace? It is impossible because you are not told what tags you are allowed to use. Myspace also does not declare a DTD, but still uses advanced tags from standards requiring a DTD </rant>
Did you get the number on that truck?
User avatar
phillipsjk
 
Posts: 1215
Joined: Wed Nov 05, 2008 4:09 pm UTC
Location: Edmonton AB Canada

Re: Text Markup languages

Postby godlygeek » Sat Jan 31, 2009 7:21 am UTC

Here's an example in reStructuredText. I find it slightly nicer to read than markdown, though I prefer both to, say, LaTeX. reST has LaTeX and HTML as output methods, and there's an experimental direct-to-pdf renderer out there... but the documents made with reST => LaTeX => PDF are nicer looking. Doing the coloring of different elements is possible, but would require a separate CSS file. After all, a large portion of the point of a language like this is to separate the text from the presentation. :-)

Code: Select all
This is a title
===============

This is a subhead
-----------------

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ornare aliquam
erat. Donec eu risus at urna vehicula interdum. Proin sodales ligula adipiscing
mauris. Suspendisse lectus leo, fermentum nec, tempus eget, rutrum quis, eros.
`This is a link`__.

__ http://docutils.sourceforge.net/docs/user/rst/quickstart.html

`Here's another link <http://www.google.com>`_

+----+--+-------+------+
|this|is|a      |header|
+====+==+=======+======+
|this|is|a      |row   |
+----+--+-------+------+
|this|is|another|row   |
+----+--+-------+------+

=======  ===========
Simpler Table Layout
--------------------
Simple   Tables
=======  ===========
Simpler  Syntax
Easier   to write
Harder   to span
=======  ===========

* unordered list item 1
* ul 2
* ul 3

1. ol 1
2. ol 2
3. ol 3

Another list, autonumbered:

#. Item 1
#. Newly inserted item
#. Item 2
#. Item 3

.. image:: rest.png
  :alt: Some alt text
godlygeek
 
Posts: 2
Joined: Sat Jan 31, 2009 6:49 am UTC


Return to Religious Wars

Who is online

Users browsing this forum: Slageammalymn and 2 guests