Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a694d103
Commit
a694d103
authored
Aug 22, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We use django-wiki's built-in wikilinks markdown extension. They were clashing.
parent
cca5fe2f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
98 deletions
+4
-98
lms/djangoapps/course_wiki/plugins/markdownedx/mdx_wikipath.py
+0
-92
lms/djangoapps/course_wiki/plugins/markdownedx/wiki_plugin.py
+2
-5
lms/envs/common.py
+1
-0
repo-requirements.txt
+1
-1
No files found.
lms/djangoapps/course_wiki/plugins/markdownedx/mdx_wikipath.py
deleted
100755 → 0
View file @
cca5fe2f
#!/usr/bin/env python
'''
Wikipath Extension for Python-Markdown
======================================
Converts [Link Name](wiki:ArticleName) to relative links pointing to article. Requires Python-Markdown 2.0+
Basic usage:
>>> import markdown
>>> text = "Some text with a [Link Name](wiki:ArticleName)."
>>> html = markdown.markdown(text, ['wikipath(base_url="/wiki/view/")'])
>>> html
u'<p>Some text with a <a class="wikipath" href="/wiki/view/ArticleName/">Link Name</a>.</p>'
Dependencies:
* [Python 2.3+](http://python.org)
* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/)
'''
import
markdown
try
:
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
# but import the 2.0.3 version if it fails
from
markdown.util
import
etree
except
:
from
markdown
import
etree
class
WikiPathExtension
(
markdown
.
Extension
):
def
__init__
(
self
,
configs
):
# set extension defaults
self
.
config
=
{
'base_url'
:
[
'/'
,
'String to append to beginning of URL.'
],
'html_class'
:
[
'wikipath'
,
'CSS hook. Leave blank for none.'
]
}
# Override defaults with user settings
for
key
,
value
in
configs
:
# self.config[key][0] = value
self
.
setConfig
(
key
,
value
)
def
extendMarkdown
(
self
,
md
,
md_globals
):
self
.
md
=
md
# append to end of inline patterns
WIKI_RE
=
r'\[(?P<linkTitle>.+?)\]\(wiki:(?P<wikiTitle>[a-zA-Z\d/_-]*)\)'
wikiPathPattern
=
WikiPath
(
WIKI_RE
,
self
.
config
)
wikiPathPattern
.
md
=
md
md
.
inlinePatterns
.
add
(
'wikipath'
,
wikiPathPattern
,
"<reference"
)
class
WikiPath
(
markdown
.
inlinepatterns
.
Pattern
):
def
__init__
(
self
,
pattern
,
config
):
markdown
.
inlinepatterns
.
Pattern
.
__init__
(
self
,
pattern
)
self
.
config
=
config
def
handleMatch
(
self
,
m
)
:
article_title
=
m
.
group
(
'wikiTitle'
)
if
article_title
.
startswith
(
"/"
):
article_title
=
article_title
[
1
:]
url
=
self
.
config
[
'base_url'
][
0
]
+
article_title
label
=
m
.
group
(
'linkTitle'
)
a
=
etree
.
Element
(
'a'
)
a
.
set
(
'href'
,
url
)
a
.
text
=
label
if
self
.
config
[
'html_class'
][
0
]:
a
.
set
(
'class'
,
self
.
config
[
'html_class'
][
0
])
return
a
def
_getMeta
(
self
):
""" Return meta data or config data. """
base_url
=
self
.
config
[
'base_url'
][
0
]
html_class
=
self
.
config
[
'html_class'
][
0
]
if
hasattr
(
self
.
md
,
'Meta'
):
if
self
.
md
.
Meta
.
has_key
(
'wiki_base_url'
):
base_url
=
self
.
md
.
Meta
[
'wiki_base_url'
][
0
]
if
self
.
md
.
Meta
.
has_key
(
'wiki_html_class'
):
html_class
=
self
.
md
.
Meta
[
'wiki_html_class'
][
0
]
return
base_url
,
html_class
def
makeExtension
(
configs
=
None
)
:
return
WikiPathExtension
(
configs
=
configs
)
if
__name__
==
"__main__"
:
import
doctest
doctest
.
testmod
()
lms/djangoapps/course_wiki/plugins/markdownedx/wiki_plugin.py
View file @
a694d103
...
...
@@ -5,18 +5,15 @@ from django.core.urlresolvers import reverse_lazy
from
wiki.core.plugins.base
import
BasePlugin
from
wiki.core.plugins
import
registry
as
plugin_registry
from
course_wiki.plugins.markdownedx
import
mdx_circuit
,
mdx_
wikipath
,
mdx_
mathjax
,
mdx_video
from
course_wiki.plugins.markdownedx
import
mdx_circuit
,
mdx_mathjax
,
mdx_video
class
ExtendMarkdownPlugin
(
BasePlugin
):
"""
This plugin simply loads all of the markdown extensions we use in edX.
"""
wiki_base_url
=
reverse_lazy
(
"wiki:get"
,
kwargs
=
{
'path'
:
""
})
markdown_extensions
=
[
mdx_circuit
.
CircuitExtension
(
configs
=
{}),
#mdx_image.ImageExtension() , #This one doesn't work. Tries to import simplewiki.settings
mdx_wikipath
.
WikiPathExtension
(
configs
=
{
'base_url'
:
wiki_base_url
}
.
iteritems
()
)
,
mdx_mathjax
.
MathJaxExtension
(
configs
=
{})
,
mdx_video
.
VideoExtension
(
configs
=
{})]
...
...
lms/envs/common.py
View file @
a694d103
...
...
@@ -585,6 +585,7 @@ INSTALLED_APPS = (
'mptt'
,
'sekizai'
,
#'wiki.plugins.attachments',
'wiki.plugins.links'
,
'wiki.plugins.notifications'
,
'course_wiki.plugins.markdownedx'
,
...
...
repo-requirements.txt
View file @
a694d103
-e git://github.com/MITx/django-staticfiles.git@6d2504e5c8#egg=django-staticfiles
-e git://github.com/MITx/django-pipeline.git#egg=django-pipeline
-e git://github.com/benjaoming/django-wiki.git@
63003aa
#egg=django-wiki
-e git://github.com/benjaoming/django-wiki.git@
3576a2d
#egg=django-wiki
-e git://github.com/dementrock/pystache_custom.git@776973740bdaad83a3b029f96e415a7d1e8bec2f#egg=pystache_custom-dev
-e common/lib/capa
-e common/lib/xmodule
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment