curlysemi / wittgenstein

a markup language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

<style> ol.wit-nest { counter-reset: item } li.wit-item { display: block } li.wit-item:before { content: counters(item, ".") ". "; counter-increment: item } li.wit-item:before { color: mistyrose; } li.wit-collapsed:before { color: red; } ol.wit-nest p { display: inline; } .wit-hide { display: none; } </style>

Wittgenstein Markup Language (.wit)

The markup language dedicated to writing complicated, nested lists. You could use it to write the next Tractatus Logico-Philosophicus and not have to worry about the numberings (they're all done automatically). 🙂

What Wittgenstein Does

Aren't truth tables a great way of organizing the values of logical expressions? Don't forget that Wittgenstein invented truth tables as (basically) an aside in his Tractatus Logico-Philosophicus. The organizational structure of that work itself is also a great organizational system — it provides a powerful way of organizing related comments/statements/propositions/sections. Whoever wants to make notes quickly in that style can now rejoice, because the Wittgenstein Markup Language takes care of all the hard numbering/sub-sectioning work!

Why not just use Markdown? Markdown doesn't support nested numbering like the following:

  1. First item

    1. First item's first sub-item

  2. Second Item

If you tried to do it, you might write something like this:

1. First item
    1.1. First item's first sub-item
2. Second Item

But you would unfortunately get something that looks like this:

  1. First item 1.1. First item's first sub-item
  2. Second Item

While you could manage the numbering by hand manually via some hacky solutions, if you later need to insert an item, you have to do a lot of renumbering. It sucks and is not something you can do easily once you start having to manage larger nested lists.

Our renumbering concern applies to the normal ordered lists that Markdown supports. They might seem nice in principle:

1. First Item
2. Second Item
3. Third Item

(Which produces the following:)

  1. First Item
  2. Second Item
  3. Third Item

But, again, there's something really annoying about having to renumber extensive lists.

So, as an alternate syntax, how about this instead?:

1* First Item
* Second Item
* Third Item

It should be enough to show that the intent was an ordered list using numbers with the first list element by simply doing 1* and using only * for the subsequent list elements. (In the future, we ought to be able to support a*, too.)

And, it works:

  1. First Item

  2. Second Item

  3. Third Item

Now, taking the previous innovation in mind, we added support for our numbered nesting simply by indicating each level clearly.

So, here is the original markup for the first example we gave:

1* First item
    * First item's first sub-item
* Second Item

And it works, too, because this very README used this Wittgenstein-influenced markup language to produce its examples. (The very first example of a list we gave in this README was originally written in this style.)

So, basically, when nesting, indent (with 4 spaces) and use *s as you would normally, and Wittgenstein does the rest! Just remember to preface your first star with a 1.

How Wittgenstein Works

Keep in mind this is a proof-of-concept written on a Saturday night. Currently, it's a simply Python3 script that does a relatively light transformation on the lines of an inputted text file that start with * or 1* (excluding whitespace to also handle lines that correspond to sub-items).

It was first a simple generator of indentions for plaintext files and then I decided I wanted to be able to generate Markdown files. Since Markdown supports HTML, the way Wittgenstein works for Markdown is to simply generate HTML tags and let CSS handle the numbering. (Since I added support for Markdown after I had figured out the more-straightforward indention logic for plaintext (which didn't actually require me to do any lookaheads or lookbacks), the logic I added for handling nested HTML tags is confusing as heck — but it works.)

Apparently, GitHub doesn't support <styles> in Markdown, so the numbering appears slightly incorrect there — instead of 1.1.1., we get 1.i.a. 😭

There's still support for the plain, indention-based numbering. I'm leaving the HTML mode as the default because it is more impressive.

Complicated Examples

The following is a complicated nesting example (I'm actually using this README to hold the test cases since this README is written in the .wit markup language and is simple being exported to Markdown.).

  1. The world is all that is the case.

    1. The world is the totality of facts, not of things.

      1. The world is determined by the facts, and by their being all the facts.

      2. For the totality of facts determines what is the case, and also whatever is not the case.

      3. The facts in logical space are the world.

    2. The world divides into facts.

      1. Each item can be the case or not the case while everything else remains the same.

And because I don't wish to include the full Tractatus Logico-Philosophicus in this README, we'll provide an nesting edge-case:

  1. This is a simple item

        1. This is a complicated item with some empty parent nodes

      1. This is actually a more complicated item

        1. An earlier version had bugs and gave the wrong numbers in these situations

  2. This is another simple item

    1. We want to make sure that this item (and its successors) is numbered properly

      1. Is this one numbered correctly?

        1. What about this one?

        2. Don't forget this one!

  3. What about support for Markdown syntax in the items themselves?

  4. If I want to be able to link, I have to give the line an ID

    1. Don't forget nested ones!

  5. Then, if I want to make a link, I can simply refer to §4.

    1. I can also refer to §4.1 (as well as §4 in the same line)

      1. And I can refer to §6


        This is a continuation. Bacon ipsum dolor amet pork belly tail pancetta shank salami venison andouille fatback ball tip. Biltong tail pig spare ribs tri-tip shankle. Jerky fatback salami picanha t-bone corned beef landjaeger. Meatball cupim jerky, ball tip flank shoulder tongue pancetta. Meatloaf pork loin pancetta brisket. Sausage shoulder alcatra beef, pancetta swine pork belly boudin tri-tip turducken andouille hamburger ball tip buffalo prosciutto. Short ribs ham hock tongue, salami pig swine turducken cupim tenderloin ribeye cow fatback venison andouille.


        Pancetta pastrami sausage jowl frankfurter, flank landjaeger pork spare ribs shankle. Chislic capicola alcatra venison andouille pork ham hock pork belly drumstick shank meatball tongue tenderloin jerky. Turkey jowl jerky chicken rump short loin buffalo strip steak pancetta. Venison brisket ball tip, turducken shank meatloaf flank alcatra beef ribs andouille filet mignon tongue.

  6. Despite the line break above, we have decided we want to consider this part of the same list to allow for more formatting flexibility

  • BUT, this line starts a new list (because there's two blank lines) (and isn't numbered because it doesn't start with 1*)

Dependencies

pip3 install markdown

Future Changes

  • Support LaTeX as an output.
  • Support a* listing.
  • Support N* listing, where N is any number (right now we can only start at 1)
  • Support w* listing (one that uses the exact style of numbering that the Tractatus Logico-Philosophicus does — though I like the style of this version more, we handle empty nodes differently than the TLP and end up with different numbers.)
  • There's some other stuff I'd like have a markup language support (such as simple diagrams), though I'm undecided on a syntax for the time being — this project may grow to support other newish markup features.
  • Support numbering in >s
<script> var witItems = document.getElementsByClassName("wit-item"); for (var i = 0; i < witItems.length; i++) { witItems[i].addEventListener("click", function(event) { if (event.target !== this && event.target.nodeName === 'A' && event.target.href) { return; } var contentID = this.getAttribute('data-wit-content-id'); var content = document.getElementById(contentID); if (content) { this.classList.toggle("wit-collapsed"); content.classList.toggle("wit-hide"); } event.stopPropagation(); }); }</script>

About

a markup language

License:MIT License


Languages

Language:Python 100.0%