Making a transform from markdown to XPress Tags

I am considering making a way to export content from Plone to QuarkXpress (desktop publishing).

To make a view that takes fields and export them is not too hard, but it would be nice to transform from markdown to XPressTags.

The format is very easy, and a bit similar to html:

# My title  would be something like  @Title:My Title

*italic* would be <I>Italic<I> (notice no end tag)
**bold** would be <B>bold<B>

So, how would a make such a transform, and should I ? Is it better to look at collective.csvexport or something similar.?

Take a look at plone.intelligenttext. That should give you enough pointers to get started.

Though I don't think this will bring you anything; do you want to import data with basic styling into a DTP application?

Yes, that is what I plan to do… ( I am pretty good at this but I have been using different approaches (like CSV, Excel, XML, AppleScript).

Things has changed in the DTP (QuarkXpress) program, making it much more interesting to do it this way (what earlier needed several text boxes can now be done in one, meaning that one can do everything in one export / import instead of 'far too many' as it was before. Also, I noticed that someone just made something that does it 'the other way'… https://pypi.python.org/pypi/Quark-Xpress-Tags-to-xml/1.0

It looks to me that a lot of code is also in Products.PortalTransforms ( https://github.com/plone/Products.PortalTransforms/blob/master/Products/PortalTransforms/transforms/web_intelligent_plain_text_to_html.py )
I would guess that the 'correct way' would be to add another entry to @@markup-controlpanel (or would it be ok to just use 'text/plain' ?

PS: I will not need a transform FROM html.

OK, I have gotten a bit further, so I have another question:

To me, it looks like the best approach would be to have another option in the markup settings.
( /@@markup-controlpanel )

Since my 'tags' probably 'technically is plain text', I wonder:

Can I invent a mime type and add it ?

PS: I did try:

<registry>
    <record name="plone.allowed_types" interface="Products.CMFPlone.interfaces.controlpanel.IMarkupSchema" field="allowed_types">
  <field type="plone.registry.field.Tuple">
    <default>
      <element>text/x-xtags</element>
    </default>
      <value_type type="plone.registry.field.Choice">
    <vocabulary>plone.app.vocabularies.AllowableContentTypes</vocabulary>
  </value_type>
</field>
      Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 687, in __call__
  Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 452, in install_product
  Module Products.GenericSetup.tool, line 388, in runAllImportStepsFromProfile
  __traceback_info__: profile-collective.transform.xtags:default
  Module Products.GenericSetup.tool, line 1433, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 1245, in _doRunImportStep
  __traceback_info__: plone.app.registry
  Module plone.app.registry.exportimport.handler, line 79, in importRegistry
  __traceback_info__: registry.xml
  Module plone.app.registry.exportimport.handler, line 125, in importDocument
  Module plone.app.registry.exportimport.handler, line 245, in importRecord
  __traceback_info__: record name: plone.allowed_types
  Module plone.supermodel.exportimport, line 148, in read
  Module zope.schema._bootstrapfields, line 52, in __set__
  Module zope.schema._bootstrapfields, line 183, in validate
  Module zope.schema._field, line 527, in _validate
  WrongContainedType: ([ConstraintNotSatisfied('text/x-x-tags', '')], '')

If I understand correctly, you tried to add a record with registry import, right ?
warning, registry import is not additive, when you have multiple values like
text/html
text/x-web-textile
if you import another value, the prior one will be deleted.
and the imported values can be controlled by the registry, here from
<value_type type="plone.registry.field.Choice">
plone.app.vocabularies.AllowableContentTypes

also you should notice from this thread that
content_type_registry/manage_predicates is the way to go.

I am not completely sure what I am 'trying to do'.
In the UI, I want to to work like this:

  1. In /@@markup settings, add a new 'type' ( text/mycodes or something )
  2. Add a new page (or similar)
  3. Choose 'text/mycodes' instead of html
  4. Paste (or upload) the text that I get from the layout program.
  5. Render this as html

yes indeed portal_transform seems your best bet

Currently, I dont have a 'real use case' for this, so I have changed my mind a little:

Anyway: I got Xpress Tags to html transform mostly working, which means one can:

  1. Export text from Quark Xpress (DTP program)
  2. Import it in Plone
  3. Render it as html
  4. Do edits in the Tagged text in Plone (with preview)
  5. Reimport the TAGS to Quark Xpress.

This could be used to let those who do not have Quark Xpress do proofing etc