Skip to content

Commit

Permalink
Added format processing of comment fields see issue (schemaorg#181)
Browse files Browse the repository at this point in the history
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
RichardWallis committed Apr 4, 2016
1 parent 77909f7 commit 33388e1
Show file tree
Hide file tree
Showing 43 changed files with 6,178 additions and 11 deletions.
28 changes: 25 additions & 3 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand All @@ -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()

6 changes: 6 additions & 0 deletions appengine_config.py
Original file line number Diff line number Diff line change
@@ -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')
9 changes: 3 additions & 6 deletions data/schema.rdfa
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down
47 changes: 47 additions & 0 deletions lib/Markdown-2.6.6-py2.7.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions lib/Markdown-2.6.6-py2.7.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/Markdown-2.6.6-py2.7.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

66 changes: 66 additions & 0 deletions lib/Markdown-2.6.6-py2.7.egg-info/installed-files.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/Markdown-2.6.6-py2.7.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
markdown
Loading

0 comments on commit 33388e1

Please sign in to comment.