Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
2
2015-12-uni-ffm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CmS
2015-12-uni-ffm
Commits
d9c94749
Commit
d9c94749
authored
11 years ago
by
Hakim El Hattab
Browse files
Options
Downloads
Patches
Plain Diff
markdown refactoring #507
parent
e9b0f5b4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugin/markdown/markdown.js
+31
-9
31 additions, 9 deletions
plugin/markdown/markdown.js
with
31 additions
and
9 deletions
plugin/markdown/markdown.js
+
31
−
9
View file @
d9c94749
...
@@ -3,7 +3,17 @@
...
@@ -3,7 +3,17 @@
* markdown inside of presentations as well as loading
* markdown inside of presentations as well as loading
* of external markdown documents.
* of external markdown documents.
*/
*/
(
function
(){
(
function
(
root
,
factory
)
{
if
(
typeof
exports
===
'
object
'
)
{
module
.
exports
=
factory
(
require
(
'
./marked
'
)
);
}
else
{
// Browser globals (root is window)
root
.
returnExports
=
factory
(
root
.
marked
);
root
.
returnExports
.
processSlides
();
root
.
returnExports
.
convertSlides
();
}
}(
this
,
function
(
marked
)
{
if
(
typeof
marked
===
'
undefined
'
)
{
if
(
typeof
marked
===
'
undefined
'
)
{
throw
'
The reveal.js Markdown plugin requires marked to be loaded
'
;
throw
'
The reveal.js Markdown plugin requires marked to be loaded
'
;
...
@@ -91,7 +101,7 @@
...
@@ -91,7 +101,7 @@
* Parses a data string into multiple slides based
* Parses a data string into multiple slides based
* on the passed in separator arguments.
* on the passed in separator arguments.
*/
*/
function
slidify
Markdown
(
markdown
,
options
)
{
function
slidify
(
markdown
,
options
)
{
options
=
options
||
{};
options
=
options
||
{};
options
.
separator
=
options
.
separator
||
'
^
\n
---
\n
$
'
;
options
.
separator
=
options
.
separator
||
'
^
\n
---
\n
$
'
;
...
@@ -162,7 +172,12 @@
...
@@ -162,7 +172,12 @@
}
}
function
loadExternalMarkdown
()
{
/**
* Parses any current data-markdown slides, splits
* multi-slide markdown into separate sections and
* handles loading of external markdown.
*/
function
processSlides
()
{
var
sections
=
document
.
querySelectorAll
(
'
[data-markdown]
'
),
var
sections
=
document
.
querySelectorAll
(
'
[data-markdown]
'
),
section
;
section
;
...
@@ -187,7 +202,7 @@
...
@@ -187,7 +202,7 @@
if
(
xhr
.
readyState
===
4
)
{
if
(
xhr
.
readyState
===
4
)
{
if
(
xhr
.
status
>=
200
&&
xhr
.
status
<
300
)
{
if
(
xhr
.
status
>=
200
&&
xhr
.
status
<
300
)
{
section
.
outerHTML
=
slidify
Markdown
(
xhr
.
responseText
,
{
section
.
outerHTML
=
slidify
(
xhr
.
responseText
,
{
separator
:
section
.
getAttribute
(
'
data-separator
'
),
separator
:
section
.
getAttribute
(
'
data-separator
'
),
verticalSeparator
:
section
.
getAttribute
(
'
data-vertical
'
),
verticalSeparator
:
section
.
getAttribute
(
'
data-vertical
'
),
notesSeparator
:
section
.
getAttribute
(
'
data-notes
'
),
notesSeparator
:
section
.
getAttribute
(
'
data-notes
'
),
...
@@ -219,7 +234,7 @@
...
@@ -219,7 +234,7 @@
}
}
else
if
(
section
.
getAttribute
(
'
data-separator
'
)
)
{
else
if
(
section
.
getAttribute
(
'
data-separator
'
)
)
{
section
.
outerHTML
=
slidify
Markdown
(
getMarkdownFromSlide
(
section
),
{
section
.
outerHTML
=
slidify
(
getMarkdownFromSlide
(
section
),
{
separator
:
section
.
getAttribute
(
'
data-separator
'
),
separator
:
section
.
getAttribute
(
'
data-separator
'
),
verticalSeparator
:
section
.
getAttribute
(
'
data-vertical
'
),
verticalSeparator
:
section
.
getAttribute
(
'
data-vertical
'
),
notesSeparator
:
section
.
getAttribute
(
'
data-notes
'
),
notesSeparator
:
section
.
getAttribute
(
'
data-notes
'
),
...
@@ -231,7 +246,11 @@
...
@@ -231,7 +246,11 @@
}
}
function
convertMarkdownToHTML
()
{
/**
* Converts any current data-markdown slides in the
* DOM to HTML.
*/
function
convertSlides
()
{
var
sections
=
document
.
querySelectorAll
(
'
[data-markdown]
'
);
var
sections
=
document
.
querySelectorAll
(
'
[data-markdown]
'
);
...
@@ -254,7 +273,10 @@
...
@@ -254,7 +273,10 @@
}
}
loadExternalMarkdown
();
return
{
convertMarkdownToHTML
();
processSlides
:
processSlides
,
convertSlides
:
convertSlides
,
slidify
:
slidify
};
})
(
);
}));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment