Re: [Zim-wiki] Zim feature requests.

2012-07-07 Thread Brian Allen Vanderburg II
On Thu, 5 Jul 2012 17:36:12 +0200
Jaap Karssenberg  wrote:

> On Wed, Jul 4, 2012 at 6:16 PM, Brian Allen Vanderburg II
>  wrote:
> > I checked out zim-next and looked through some of the code.  Since
> > the data that gets passed to the exporters is already a parse tree,
> > it seems there could be a couple simpler solutions for XML export:
> >
> > 1.  Plain export of the parse tree as xml (with a root namespace).
> > My site builder allows chaining the output of one transform into
> > another based on the root element namespace, so I could then write
> > a transform that would transform the Zim xml to my document xml
> > which then would be transformed to the html result.
> >
> > I am working on implementing a simple exporter for this and have
> > attached a file with the changes.
> 
> Looks fair. Only doubt I have is that the structure that you dump
> there is something I consider an internal format that may be changed
> at will when code needs that. For export format we should probably fix
> a schema and make sure we do not change the XML accidentally.

I only tested this as a concept to see if it would work.  I agree if it
were used a schema should be defined for the exported data.
 
> How would XHTML work for you? I think a XHTML export would be used by
> much more people than some zim specific XML. You can still transform
> it like XML if you want.

XHTML would work probably fine for my needs. I'm checking to see how
much manual change I would need to current HTML exports to use with some
XSL files.

> 
> > 2.  XSL transforms on the parse tree.  This would allow creating any
> > output xml by using an xsl transform on the parse tree.  I don't
> > think Python's built-in xml modules have xsl support.  lxml does
> > but that would add another dependency to zim.
> 
> I wonder if you really need full XSL. My guess is that you would want
> to keep the content in sequence and maybe just rename some elements,
> ignore some elements, and maybe filter the tree. Is that a fair
> assumption ?
> 
> In the pyzim-next tree there is a python API for doing transforms on
> the tree (still working on it, but taking shape), so maybe for
> advanced users a simple python script can do all these things.

That sounds interesting.  I'll have to check that out later.


Brian Allen Vanderburg II


signature.asc
Description: PGP signature
___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


Re: [Zim-wiki] Zim feature requests.

2012-07-05 Thread Jaap Karssenberg
On Wed, Jul 4, 2012 at 6:16 PM, Brian Allen Vanderburg II
 wrote:
> I checked out zim-next and looked through some of the code.  Since the
> data that gets passed to the exporters is already a parse tree, it
> seems there could be a couple simpler solutions for XML export:
>
> 1.  Plain export of the parse tree as xml (with a root namespace). My
> site builder allows chaining the output of one transform into another
> based on the root element namespace, so I could then write a transform
> that would transform the Zim xml to my document xml which then would be
> transformed to the html result.
>
> I am working on implementing a simple exporter for this and have
> attached a file with the changes.

Looks fair. Only doubt I have is that the structure that you dump
there is something I consider an internal format that may be changed
at will when code needs that. For export format we should probably fix
a schema and make sure we do not change the XML accidentally.

How would XHTML work for you? I think a XHTML export would be used by
much more people than some zim specific XML. You can still transform
it like XML if you want.

> 2.  XSL transforms on the parse tree.  This would allow creating any
> output xml by using an xsl transform on the parse tree.  I don't think
> Python's built-in xml modules have xsl support.  lxml does but that
> would add another dependency to zim.

I wonder if you really need full XSL. My guess is that you would want
to keep the content in sequence and maybe just rename some elements,
ignore some elements, and maybe filter the tree. Is that a fair
assumption ?

In the pyzim-next tree there is a python API for doing transforms on
the tree (still working on it, but taking shape), so maybe for
advanced users a simple python script can do all these things.

On the other hand if there is a real use case for full XSL we can
always put it in a plugin and make the dependency optional.

Regards,

Jaap

___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


Re: [Zim-wiki] Zim feature requests.

2012-07-04 Thread Brian Allen Vanderburg II
On Wed, 4 Jul 2012 08:27:48 +0200
Jaap Karssenberg  wrote:

> On Wed, Jul 4, 2012 at 7:33 AM, Brian Allen Vanderburg II
>  wrote:
> > I've got an idea for a couple features I think would be a little
> > nice:
> >
> > XML export.
> >
> > I have a site that is static but locally stored in XML which is then
> > transformed based on the document type (root element namespace) to
> > an HTML page.  Instead of creating a template which creates the
> > entire HTML page layout (bit of duplication and any changes would
> > require changes both to my tranforms and the export templates), it
> > would be nice if I could just create a template to export to XML
> > for my custom document format.
> 
> Well, you can make a custom HTML template and use you own XML instead
> of HTML. Of course part of the elements are filled in by the export
> code. If you want to modify those, you need to copy and customize
> "zim/formats/html.py".
> 

I checked out zim-next and looked through some of the code.  Since the
data that gets passed to the exporters is already a parse tree, it
seems there could be a couple simpler solutions for XML export:

1.  Plain export of the parse tree as xml (with a root namespace). My
site builder allows chaining the output of one transform into another
based on the root element namespace, so I could then write a transform
that would transform the Zim xml to my document xml which then would be
transformed to the html result.

I am working on implementing a simple exporter for this and have
attached a file with the changes.

2.  XSL transforms on the parse tree.  This would allow creating any
output xml by using an xsl transform on the parse tree.  I don't think
Python's built-in xml modules have xsl support.  lxml does but that
would add another dependency to zim.

Brian Allen Vanderburg II
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: allen@allen-pc-20120704160952-wxejfa4bch8lg3h3
# target_branch: http://bazaar.launchpad.net/~jaap.karssenberg/zim\
#   /pyzim-next/
# testament_sha1: 3a4b44732dc1e7ded81aac63ccde22dc3a182186
# timestamp: 2012-07-04 12:12:55 -0400
# base_revision_id: par...@cpan.org-20120313150044-59s16uwtoemlo3tj
# 
# Begin patch
=== added directory 'data/templates/zimxml'
=== added file 'data/templates/zimxml/Default.xml'
--- data/templates/zimxml/Default.xml   1970-01-01 00:00:00 +
+++ data/templates/zimxml/Default.xml   2012-07-04 16:09:52 +
@@ -0,0 +1,7 @@
+
+http://www.zim-wiki.org/page"; version="1.0">
+
+[% title %]
+
+[% page.body %]
+

=== modified file 'zim.py'
--- zim.py  2011-06-30 20:49:24 +
+++ zim.py  2012-07-04 16:09:09 +
@@ -4,6 +4,8 @@
 import logging
 import os
 
+print sys.path
+
 # Check if we run the correct python version
 try:
version_info = sys.version_info

=== modified file 'zim/formats/__init__.py'
--- zim/formats/__init__.py 2012-03-13 15:00:44 +
+++ zim/formats/__init__.py 2012-07-04 16:09:09 +
@@ -155,7 +155,7 @@
 
 def list_formats(type):
if type == EXPORT_FORMAT:
-   return ['HTML','LaTeX', 'Markdown (pandoc)']
+   return ['HTML','LaTeX', 'Markdown (pandoc)', 'ZimXML (parse 
tree)']
elif type == TEXT_FORMAT:
return ['Text', 'Wiki', 'Markdown (pandoc)']
else:

=== modified file 'zim/formats/wiki.py'
--- zim/formats/wiki.py 2012-03-13 15:00:44 +
+++ zim/formats/wiki.py 2012-07-04 16:09:09 +
@@ -169,7 +169,7 @@
def parse_pre(builder, indent, text):
'''Verbatim block with indenting'''
if indent:
-   text = re.sub('^'+indent, '', text, flags=re.M) # 
remove indent
+   text = re.sub('(?m)^'+indent, '', text) # remove indent
attrib = {'indent': len(indent)}
else:
attrib = None
@@ -192,7 +192,7 @@
# accidentally
attrib['type'] = type
if indent:
-   body = re.sub('^'+indent, '', body, flags=re.M) # 
remove indent
+   body = re.sub('(?m)^'+indent, '', body) # remove indent
attrib['indent'] = len(indent)
 
builder.span(OBJECT, attrib, body)
@@ -222,7 +222,7 @@
per list item
'''
if indent:
-   text = re.sub('^'+indent, '', text, flags=re.M) # 
remove indent
+   text = re.sub('(?m)^'+indent, '', text) # remove indent
attrib = {'indent': len(indent)}
else:
attrib = None
@@ -275,7 +275,7 @@
 
def parse_indent(self, builder, text, indent):
'''Parse indented blocks and turn them into 'div' elements'''
-   text = re.sub('^'+indent, '', text, flags=re.M) # remove indent
+   text = re.sub('(?m)^'+indent, '', text) # remove indent
builder.start(BLOCK, {'indent':

Re: [Zim-wiki] Zim feature requests.

2012-07-03 Thread Jaap Karssenberg
On Wed, Jul 4, 2012 at 7:33 AM, Brian Allen Vanderburg II
 wrote:
> I've got an idea for a couple features I think would be a little nice:
>
> XML export.
>
> I have a site that is static but locally stored in XML which is then
> transformed based on the document type (root element namespace) to an
> HTML page.  Instead of creating a template which creates the entire HTML
> page layout (bit of duplication and any changes would require changes
> both to my tranforms and the export templates), it would be nice if I
> could just create a template to export to XML for my custom document
> format.

Well, you can make a custom HTML template and use you own XML instead
of HTML. Of course part of the elements are filled in by the export
code. If you want to modify those, you need to copy and customize
"zim/formats/html.py".

> Syntax highlighting.
... 8< ...

As I mentioned in the other mail, work is in progress on this item.
See the pyzim-next code tree, it has already inline code blocks with
syntax highlighting based on gtksourceview. Will take some time before
this becomes main code base, but work is progressing.

Bug report is here: https://bugs.launchpad.net/zim/+bug/275714
Code branch is here: https://code.launchpad.net/~jaap.karssenberg/zim/pyzim-next

> Named anchors in pages.
>
> The ability to link not just to a page, but to a certain location in
> the page:
>
> Top:SubPage:SubSubPage#Location

That would be this bug: https://bugs.launchpad.net/zim/+bug/380844


Please let me know if you want to help out speeding up the development
of any of these items. Quite some work to be done, and my time to work
on it is really limited the last month or two.

Regards,

Jaap

___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp


[Zim-wiki] Zim feature requests.

2012-07-03 Thread Brian Allen Vanderburg II
I've got an idea for a couple features I think would be a little nice:

XML export.

I have a site that is static but locally stored in XML which is then
transformed based on the document type (root element namespace) to an
HTML page.  Instead of creating a template which creates the entire HTML
page layout (bit of duplication and any changes would require changes
both to my tranforms and the export templates), it would be nice if I
could just create a template to export to XML for my custom document
format.

Syntax highlighting.

Support syntax highlighting in the page.  This can be built upon the
existing verbatim format.  The Pygments library could be used for
syntax highlighting. Establish syntax names as part of the wiki format
(if the syntax name changes in the library, it shouldn't break the
display in Zim, but instead Zim should keep the same name it uses and
map to the highlighter syntax name)

Any consecutive lines of verbatim text are treated as a code block.
The first line in the source file would have the syntax to use, perhaps
something like this:

''@python
'''def example():
'''print('This is a syntax highlighting example')
'''
'''def example2():
'''print('This is another example')

Named anchors in pages.

The ability to link not just to a page, but to a certain location in
the page:

Top:SubPage:SubSubPage#Location


signature.asc
Description: PGP signature
___
Mailing list: https://launchpad.net/~zim-wiki
Post to : zim-wiki@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zim-wiki
More help   : https://help.launchpad.net/ListHelp