Writing Python modules to handle a lite markup langauge

Discussion Forums discussion Writing Python modules to handle a lite markup langauge

This topic contains 0 voices and has 3 replies.

Viewing 4 posts - 1 through 4 (of 4 total)
Author Posts
Author Posts
August 12, 2009 at 5:27 pm #664


Hi PN Users

I have just written a lightweight markup language which I want to integrate within an editor and it seems to me from what I’ve read so far PN may be the product I am looking for. However, I’d just like to check that what I want to achieve is feasible within PN before I start out. Please note – I am not asking how to do any of this. I just want to know if any of it is possible.

The markup looks quite a lot like wiki markup but with a lot more structures available. I’d like to be able to create an off-line WYSIWYM editor by adding a Python module to PN. The parsing program is currently written in Perl but I was planning to port it to Python anyway.

These are my issues:

(1) Would it be possible, using PyPN to create an additional menu bar to be displayed within PN or is the Tools collection the only way to run programs?

(2) I could use the clips collections for the markup but some of what I want to do does not quite fit that paradigm. For instance I want to prepend a character to every line in a highlighted block and indent the whole block. I’m not clear how far Python will interface with the existing functions in PN? Am I asking too much?

(3) I want to create a syntax coloring scheme. I’ve already done it within EditPad but that editor allows regular expressions to match patterns. That’s quite important as my opening and closing tags are always the same so the pattern matching has to be quite sophisticated. From my cursory look at PN I can’t see any regexs in the schemes.

(4) The final operation will be to save the file, send it to the parser for translation, create the output file, save it to a default folder previously set up by the user and then finally open the output file in a browser. I would imagin that this last bit will be easy as it can all be done by a Python script kicked off by clicking a button of some sort.

I hope I am not asking too much here but I am not minded to write an entire editor from scratch!


Rob Wheeler

Kent, UK

August 13, 2009 at 8:26 am #16715

Key Master

Hi Rob,

1. Currently PyPN allows you to add entries to the Scripts window. PN now supports extending the menu as well, this just hasn’t been added to PyPN yet. No reason why it can’t be supported.

2. You can do everything that text clips can from PyPN – you have full access to the edit control (Scintilla) which has a very rich API.

3. There is currently no regex-based parser like in EditPad, but there are various ways of supporting different languages. Perhaps if you could post a sample of your code we can work out the best way to get highlighting.

4. Yes, a script entry or menu item would let you do this easily. PN also supports a project properties system that allows you to specify extra properties for the user to set on a project. These are then stored in the XML file along with the rest of the project details. This can be useful for storing and providing an interface for external tools settings.


August 13, 2009 at 9:11 am #16716


Thanks for this reply. It sounds very encouraging so I think I’ll progress with using PN. An example of an item of markup syntax that I need to hightlight would be a list like this, eg:

:Name: John Smith

:Address: 50 Church Road

:Tel: 01899 00898

I want to be able to hightlight the label in bold. The regex I use is…


Anchor to start of line

Followed by at least one tab

Followed by a colon

Followed by any string

Followed by a colon

Followed by one or more space characters

Could this be implemented in PN?

Rob Wheeler

August 13, 2009 at 11:16 am #16717

Key Master

I see, yes this is doable, although it will need me to make a few tweaks. When you send text to the output window I already use regular expressions to parse that, so I should be able to make something simple that allows this form of highlighting more generally.

Watch this space.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.