Permalink
Browse files

Added format processing of comment fields see issue (#181)

See https://daringfireball.net/projects/markdown/syntax
For links within Schema.org site use [[target]] for example [[CreativeWork]] will result in <a href="/CreativeWork">Creative Work</a>
  • Loading branch information...
1 parent 77909f7 commit 33388e1bd233479e8f7484b7e133ed95b7cab437 @RichardWallis RichardWallis committed Apr 4, 2016
Showing with 6,178 additions and 11 deletions.
  1. +25 −3 api.py
  2. +6 −0 appengine_config.py
  3. +3 −6 data/schema.rdfa
  4. +47 −0 lib/Markdown-2.6.6-py2.7.egg-info/PKG-INFO
  5. +36 −0 lib/Markdown-2.6.6-py2.7.egg-info/SOURCES.txt
  6. +1 −0 lib/Markdown-2.6.6-py2.7.egg-info/dependency_links.txt
  7. +66 −0 lib/Markdown-2.6.6-py2.7.egg-info/installed-files.txt
  8. +1 −0 lib/Markdown-2.6.6-py2.7.egg-info/top_level.txt
  9. +529 −0 lib/markdown/__init__.py
  10. +136 −0 lib/markdown/__main__.py
  11. +29 −0 lib/markdown/__version__.py
  12. +100 −0 lib/markdown/blockparser.py
  13. +572 −0 lib/markdown/blockprocessors.py
  14. +100 −0 lib/markdown/extensions/__init__.py
  15. +91 −0 lib/markdown/extensions/abbr.py
  16. +96 −0 lib/markdown/extensions/admonition.py
  17. +177 −0 lib/markdown/extensions/attr_list.py
  18. +265 −0 lib/markdown/extensions/codehilite.py
  19. +115 −0 lib/markdown/extensions/def_list.py
  20. +132 −0 lib/markdown/extensions/extra.py
  21. +112 −0 lib/markdown/extensions/fenced_code.py
  22. +321 −0 lib/markdown/extensions/footnotes.py
  23. +97 −0 lib/markdown/extensions/headerid.py
  24. +78 −0 lib/markdown/extensions/meta.py
  25. +35 −0 lib/markdown/extensions/nl2br.py
  26. +55 −0 lib/markdown/extensions/sane_lists.py
  27. +41 −0 lib/markdown/extensions/smart_strong.py
  28. +268 −0 lib/markdown/extensions/smarty.py
  29. +149 −0 lib/markdown/extensions/tables.py
  30. +310 −0 lib/markdown/extensions/toc.py
  31. +89 −0 lib/markdown/extensions/wikilinks.py
  32. +529 −0 lib/markdown/inlinepatterns.py
  33. +191 −0 lib/markdown/odict.py
  34. +111 −0 lib/markdown/postprocessors.py
  35. +346 −0 lib/markdown/preprocessors.py
  36. +282 −0 lib/markdown/serializers.py
  37. +371 −0 lib/markdown/treeprocessors.py
  38. +177 −0 lib/markdown/util.py
  39. +7 −0 requirements.txt
  40. +2 −2 sdoapp.py
  41. +8 −0 tests/test_basics.py
  42. +1 −0 tests/test_graphs.py
  43. +71 −0 vendor.py
View
@@ -473,7 +473,7 @@ def GetComment(node, layers='core') :
"""Get the first rdfs:comment we find on this node (or "No comment"), within any of the specified layers."""
tx = GetTargets(Unit.GetUnit("rdfs:comment"), node, layers=layers )
if len(tx) > 0:
- return tx[0]
+ return MD.parse(tx[0])
else:
return "No comment"
@@ -858,10 +858,12 @@ def read_examples(files):
parser.parse(example_contents)
def StripHtmlTags(source):
- return re.sub('<[^<]+?>', '', source)
+ if source and len(source) > 0:
+ return re.sub('<[^<]+?>', '', source)
+ return ""
def ShortenOnSentence(source,lengthHint=250):
- if len(source) > lengthHint:
+ if source and len(source) > lengthHint:
source = source.strip()
sentEnd = re.compile('[.!?]')
sentList = sentEnd.split(source)
@@ -886,3 +888,23 @@ def ShortenOnSentence(source,lengthHint=250):
com += ".."
source = com
return source
+
+class MarkdownTool():
+ def __init__ (self):
+ import markdown
+ from markdown.extensions.wikilinks import WikiLinkExtension
+ self._md = markdown.Markdown(extensions=[WikiLinkExtension(base_url='/', end_url='', html_class='localLink')])
+
+ def parse(self,source,preservePara=False):
+ if not source or len(source) == 0:
+ return ""
+ source = source.replace("\\n","\n")
+ ret = self._md.reset().convert(source)
+ if not preservePara:
+ #Remove wrapping <p> </p> that Markdown adds by default
+ if len(ret) > 7 and ret.startswith("<p>") and ret.endswith("</p>"):
+ ret = ret[3:len(ret)-4]
+ return ret
+
+MD = MarkdownTool()
+
View
@@ -0,0 +1,6 @@
+"""`appengine_config` gets loaded when starting a new application instance."""
+import vendor
+# insert `lib` as a site directory so our `main` module can load
+# third-party libraries, and override built-ins with newer
+# versions.
+vendor.add('lib')
View
@@ -2988,7 +2988,7 @@
<div typeof="rdfs:Class" resource="http://schema.org/CheckInAction">
<span class="h" property="rdfs:label">CheckInAction</span>
- <span property="rdfs:comment">The act of an agent communicating (service provider, social media, etc) their arrival by registering/confirming for a previously reserved service (e.g. flight check in) or at a place (e.g. hotel), possibly resulting in a result (boarding pass, etc).&lt;p&gt;Related actions:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://schema.org/CheckOutAction&quot;&gt;CheckOutAction&lt;/a&gt;: The antonym of CheckInAction.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://schema.org/ArriveAction&quot;&gt;ArriveAction&lt;/a&gt;: Unlike ArriveAction, CheckInAction implies that the agent is informing/confirming the start of a previously reserved service.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://schema.org/ConfirmAction&quot;&gt;ConfirmAction&lt;/a&gt;: Unlike ConfirmAction, CheckInAction implies that the agent is informing/confirming the *start* of a previously reserved service rather than its validity/existence&lt;/li&gt;&lt;/ul&gt;.</span>
+ <span property="rdfs:comment">The act of an agent communicating (service provider, social media, etc) their arrival by registering/confirming for a previously reserved service (e.g. flight check in) or at a place (e.g. hotel), possibly resulting in a result (boarding pass, etc).\n\nRelated actions:\n\n* [[CheckOutAction]]: The antonym of CheckInAction.\n* [[ArriveAction]]: Unlike ArriveAction, CheckInAction implies that the agent is informing/confirming the start of a previously reserved service.\n* [[ConfirmAction]]: Unlike ConfirmAction, CheckInAction implies that the agent is informing/confirming the *start* of a previously reserved service rather than its validity/existence.</span>
<span>Subclass of: <a property="rdfs:subClassOf" href="http://schema.org/CommunicateAction">CommunicateAction</a></span>
</div>
@@ -7005,7 +7005,6 @@ Note that Event uses startDate/endDate instead of startTime/endTime, even when d
<div typeof="rdf:Property" resource="http://schema.org/sponsor">
<span class="h" property="rdfs:label">sponsor</span>
<span property="rdfs:comment">A person or organization that supports a thing through a pledge, promise, or financial contribution. e.g. a sponsor of a Medical Study or a corporate sponsor of an event.</span>
- <span>Domain: <a property="http://schema.org/domainIncludes" href="http://schema.org/MedicalStudy">MedicalStudy</a></span>
<span>Domain: <a property="http://schema.org/domainIncludes" href="http://schema.org/Person">Person</a></span>
<span>Domain: <a property="http://schema.org/domainIncludes" href="http://schema.org/Organization">Organization</a></span>
<span>Domain: <a property="http://schema.org/domainIncludes" href="http://schema.org/Event">Event</a></span>
@@ -7628,7 +7627,7 @@ Note that Event uses startDate/endDate instead of startTime/endTime, even when d
<div typeof="http://schema.org/Organization" resource="http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_bibex">
<span property="rdfs:label">BibExTerm</span>
- <span property="rdfs:comment">The W3C &lt;a href="http://www.w3.org/community/schemabibex/"&gt;Schema Bib Extend&lt;/a&gt; (BibEx) group led the work to improve schema.org for bibliographic information, including terms for periodicals, articles and multi-volume works. The design was inspired in places (e.g. pageStart, pageEnd, pagination) by the &lt;a href="http://bibliontology.com/"&gt;Bibliographic Ontology&lt;/a&gt;, 'bibo'.</span>
+ <span property="rdfs:comment">The W3C [Schema Bib Extend](http://www.w3.org/community/schemabibex/) (BibEx) group led the work to improve schema.org for bibliographic information, including terms for periodicals, articles and multi-volume works. The design was inspired in places (e.g. [[pageStart]], [[pageEnd]], [[pagination]]) by the [Bibliographic Ontology](http://bibliontology.com/), 'bibo'.</span>
</div>
<div typeof="http://schema.org/Organization" resource="http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#Automotive_Ontology_Working_Group">
@@ -8640,9 +8639,7 @@ postponing for 1.6.
<div typeof="rdfs:Class" resource="http://schema.org/Periodical">
<span class="h" property="rdfs:label">Periodical</span>
- <span property="rdfs:comment">A publication in any medium issued in successive parts bearing numerical or chronological designations and intended, such as a magazine, scholarly journal, or newspaper to continue indefinitely.
-
- &lt;br/&gt;&lt;br/&gt;See also &lt;a href="http://blog.schema.org/2014/09/schemaorg-support-for-bibliographic_2.html"&gt;blog post&lt;/a&gt;.</span>
+ <span property="rdfs:comment">A publication in any medium issued in successive parts bearing numerical or chronological designations and intended, such as a magazine, scholarly journal, or newspaper to continue indefinitely.\n\nSee also [blog post](http://blog.schema.org/2014/09/schemaorg-support-for-bibliographic_2.html).</span>
<span>Subclass of: <a property="rdfs:subClassOf" href="http://schema.org/CreativeWorkSeries">CreativeWorkSeries</a></span>
<link property="owl:equivalentClass" href="http://purl.org/ontology/bibo/Periodical"/>
<span>Source: <a property="dc:source" href="http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_bibex">BibEx</a></span>
@@ -0,0 +1,47 @@
+Metadata-Version: 1.1
+Name: Markdown
+Version: 2.6.6
+Summary: Python implementation of Markdown.
+Home-page: https://pythonhosted.org/Markdown/
+Author: Waylan Limberg
+Author-email: waylan.limberg [at] icloud.com
+License: BSD License
+Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-2.6.6.tar.gz
+Description:
+ This is a Python implementation of John Gruber's Markdown_.
+ It is almost completely compliant with the reference implementation,
+ though there are a few known issues. See Features_ for information
+ on what exactly is supported and what is not. Additional features are
+ supported by the `Available Extensions`_.
+
+ .. _Markdown: http://daringfireball.net/projects/markdown/
+ .. _Features: https://pythonhosted.org/Markdown/index.html#Features
+ .. _`Available Extensions`: https://pythonhosted.org/Markdown/extensions/index.html
+
+ Support
+ =======
+
+ You may ask for help and discuss various other issues on the
+ `mailing list`_ and report bugs on the `bug tracker`_.
+
+ .. _`mailing list`: http://lists.sourceforge.net/lists/listinfo/python-markdown-discuss
+ .. _`bug tracker`: http://github.com/waylan/Python-Markdown/issues
+
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Topic :: Communications :: Email :: Filters
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
+Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
+Classifier: Topic :: Software Development :: Documentation
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Text Processing :: Filters
+Classifier: Topic :: Text Processing :: Markup :: HTML
@@ -0,0 +1,36 @@
+setup.cfg
+Markdown.egg-info/PKG-INFO
+Markdown.egg-info/SOURCES.txt
+Markdown.egg-info/dependency_links.txt
+Markdown.egg-info/top_level.txt
+bin/markdown_py
+markdown/__init__.py
+markdown/__main__.py
+markdown/__version__.py
+markdown/blockparser.py
+markdown/blockprocessors.py
+markdown/inlinepatterns.py
+markdown/odict.py
+markdown/postprocessors.py
+markdown/preprocessors.py
+markdown/serializers.py
+markdown/treeprocessors.py
+markdown/util.py
+markdown/extensions/__init__.py
+markdown/extensions/abbr.py
+markdown/extensions/admonition.py
+markdown/extensions/attr_list.py
+markdown/extensions/codehilite.py
+markdown/extensions/def_list.py
+markdown/extensions/extra.py
+markdown/extensions/fenced_code.py
+markdown/extensions/footnotes.py
+markdown/extensions/headerid.py
+markdown/extensions/meta.py
+markdown/extensions/nl2br.py
+markdown/extensions/sane_lists.py
+markdown/extensions/smart_strong.py
+markdown/extensions/smarty.py
+markdown/extensions/tables.py
+markdown/extensions/toc.py
+markdown/extensions/wikilinks.py
@@ -0,0 +1,66 @@
+../markdown/__init__.py
+../markdown/__main__.py
+../markdown/__version__.py
+../markdown/blockparser.py
+../markdown/blockprocessors.py
+../markdown/inlinepatterns.py
+../markdown/odict.py
+../markdown/postprocessors.py
+../markdown/preprocessors.py
+../markdown/serializers.py
+../markdown/treeprocessors.py
+../markdown/util.py
+../markdown/extensions/__init__.py
+../markdown/extensions/abbr.py
+../markdown/extensions/admonition.py
+../markdown/extensions/attr_list.py
+../markdown/extensions/codehilite.py
+../markdown/extensions/def_list.py
+../markdown/extensions/extra.py
+../markdown/extensions/fenced_code.py
+../markdown/extensions/footnotes.py
+../markdown/extensions/headerid.py
+../markdown/extensions/meta.py
+../markdown/extensions/nl2br.py
+../markdown/extensions/sane_lists.py
+../markdown/extensions/smart_strong.py
+../markdown/extensions/smarty.py
+../markdown/extensions/tables.py
+../markdown/extensions/toc.py
+../markdown/extensions/wikilinks.py
+../markdown/__init__.pyc
+../markdown/__main__.pyc
+../markdown/__version__.pyc
+../markdown/blockparser.pyc
+../markdown/blockprocessors.pyc
+../markdown/inlinepatterns.pyc
+../markdown/odict.pyc
+../markdown/postprocessors.pyc
+../markdown/preprocessors.pyc
+../markdown/serializers.pyc
+../markdown/treeprocessors.pyc
+../markdown/util.pyc
+../markdown/extensions/__init__.pyc
+../markdown/extensions/abbr.pyc
+../markdown/extensions/admonition.pyc
+../markdown/extensions/attr_list.pyc
+../markdown/extensions/codehilite.pyc
+../markdown/extensions/def_list.pyc
+../markdown/extensions/extra.pyc
+../markdown/extensions/fenced_code.pyc
+../markdown/extensions/footnotes.pyc
+../markdown/extensions/headerid.pyc
+../markdown/extensions/meta.pyc
+../markdown/extensions/nl2br.pyc
+../markdown/extensions/sane_lists.pyc
+../markdown/extensions/smart_strong.pyc
+../markdown/extensions/smarty.pyc
+../markdown/extensions/tables.pyc
+../markdown/extensions/toc.pyc
+../markdown/extensions/wikilinks.pyc
+.
+dependency_links.txt
+PKG-INFO
+SOURCES.txt
+top_level.txt
+../../../bin/markdown_py
@@ -0,0 +1 @@
+markdown
Oops, something went wrong.

0 comments on commit 33388e1

Please sign in to comment.