views:

123

answers:

2

The majority of pyparsing examples that I have seen have dealt with linear expressions.

a = 1 + 2

I'd like to parse mediawiki headlines, and hash them to their sections.

e.g.

Introduction goes here
==Hello==
foo
foo
===World===
bar
bar

Dict would look like:

{'Introduction':'Whoot introduction goes here', 'Hello':"foo\nfoo", 'World':"bar\nbar"}

If I could just see one example of this "enclosed" (==HEADLINE==) parsing, I'd be able to move on to links/images/files etc.

+3  A: 

Did you miss this wiki-like language parser in the pyParsing web site examples?

h2 = QuotedString("==")
Jonathan Feinberg
Alas, it would seem so.
Nazarius Kappertaal
+1  A: 

Also, this format is not unlike a .INI file:

[section1]
a = 1
b = 3
[section2]
blah=a

Which can be parsed into a nested dictionary using this example code.

Paul McGuire