1. Akash Sinha
  2. moin2

Commits

Thomas Waldmann  committed 7200998

add a dom -> text/plain output converter, use it to create indexable content

  • Participants
  • Parent commits 5158f02
  • Branches default

Comments (0)

Files changed (2)

File MoinMoin/converter/__init__.py

View file
  • Ignore whitespace
         # converters so they emit different output than for normal rendering),
         # esp. for the non-markup content types (images, etc.).
         input_contenttype = rev[CONTENTTYPE]
-        output_contenttype = 'text/x-rst'
+        output_contenttype = 'text/plain'
         reg = default_registry
         input_conv = reg.get(Type(input_contenttype), type_moin_document)
         if not input_conv:

File MoinMoin/converter/text_out.py

View file
  • Ignore whitespace
+# Copyright: 2011 MoinMoin:ThomasWaldmann
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+
+"""
+MoinMoin - plain text output converter
+
+Converts an internal document tree into plain, unformatted text.
+
+The purpose of this converter is mainly to be used in a converter chain like
+markup -> dom -> text and get rid of the (wiki, rst, docbook, ...) markup that
+way, so we get indexable plain text for our search index.
+"""
+
+
+from __future__ import absolute_import, division
+
+
+class Converter(object):
+    """
+    Converter application/x.moin.document -> text/plain
+    """
+    @classmethod
+    def factory(cls, input, output, **kw):
+        return cls()
+
+    def __call__(self, root):
+        return u'\n'.join(root.itertext())
+
+
+from . import default_registry
+from MoinMoin.util.mime import Type, type_moin_document
+default_registry.register(Converter.factory, type_moin_document, Type('text/plain'))
+