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
d844195b
Commit
d844195b
authored
11 years ago
by
Hakim El Hattab
Browse files
Options
Downloads
Patches
Plain Diff
format tweaks markdown.js, remove extra image asset
parent
6cf5269b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugin/markdown/markdown.js
+17
-13
17 additions, 13 deletions
plugin/markdown/markdown.js
test/red-curtain-50x50.jpg
+0
-0
0 additions, 0 deletions
test/red-curtain-50x50.jpg
test/test-element-attributes-markdown.html
+5
-7
5 additions, 7 deletions
test/test-element-attributes-markdown.html
with
22 additions
and
20 deletions
plugin/markdown/markdown.js
+
17
−
13
View file @
d844195b
...
...
@@ -28,7 +28,7 @@
var
DEFAULT_SLIDE_SEPARATOR
=
'
^
\n
---
\n
$
'
,
DEFAULT_NOTES_SEPARATOR
=
'
note:
'
;
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR
=
'
{
\\\
.
\
s*?([^}]+?)}
'
;
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR
=
'
{
_
\
s*?([^}]+?)}
'
;
/**
...
...
@@ -277,46 +277,50 @@
* directly on refresh (F5)
* http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
*/
function
addAttributeInElement
(
node
,
elementTarget
,
separator
){
function
addAttributeInElement
(
node
,
elementTarget
,
separator
)
{
var
mardownClassesInElementsRegex
=
new
RegExp
(
separator
,
'
mg
'
);
var
mardownClassRegex
=
new
RegExp
(
"
([^
\"
= ]+?)=
\"
([^
\"
=]+?)
\"
"
,
'
mg
'
);
var
nodeValue
=
node
.
nodeValue
;
if
(
matches
=
mardownClassesInElementsRegex
.
exec
(
nodeValue
)
)
{
if
(
matches
=
mardownClassesInElementsRegex
.
exec
(
nodeValue
)
)
{
var
classes
=
matches
[
1
];
nodeValue
=
nodeValue
.
substring
(
0
,
matches
.
index
)
+
nodeValue
.
substring
(
mardownClassesInElementsRegex
.
lastIndex
);
node
.
nodeValue
=
nodeValue
;
while
(
matchesClass
=
mardownClassRegex
.
exec
(
classes
)
)
{
elementTarget
.
setAttribute
(
matchesClass
[
1
],
matchesClass
[
2
]);
elementTarget
.
setAttribute
(
matchesClass
[
1
],
matchesClass
[
2
]
);
}
}
}
/**
* Add attributes to the parent element of a text node,
* or the element of an attribute node.
*/
function
addAttributes
(
element
,
separator
)
{
if
(
element
.
childNodes
.
length
>
0
)
{
function
addAttributes
(
element
,
separator
)
{
for
(
var
i
=
0
;
i
<
element
.
childNodes
.
length
;
i
++
)
{
if
(
element
.
childNodes
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
element
.
childNodes
.
length
;
i
++
)
{
addAttributes
(
element
.
childNodes
[
i
],
separator
);
}
}
var
nodeValue
;
var
elementTarget
;
// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
if
(
element
.
nodeType
==
Node
.
TEXT_NODE
&&
/
\S
/
.
test
(
element
.
nodeValue
)
)
{
if
(
element
.
nodeType
==
Node
.
TEXT_NODE
&&
/
\S
/
.
test
(
element
.
nodeValue
)
)
{
addAttributeInElement
(
element
,
element
.
parentNode
,
separator
);
}
if
(
element
.
nodeType
==
Node
.
ELEMENT_NODE
&&
element
.
attributes
.
length
>
0
)
{
for
(
iattr
=
0
;
iattr
<
element
.
attributes
.
length
;
iattr
++
){
var
attr
=
element
.
attributes
[
iattr
];
addAttributeInElement
(
attr
,
element
,
separator
)
if
(
element
.
nodeType
==
Node
.
ELEMENT_NODE
&&
element
.
attributes
.
length
>
0
)
{
for
(
var
j
=
0
;
j
<
element
.
attributes
.
length
;
j
++
){
var
attr
=
element
.
attributes
[
j
];
addAttributeInElement
(
attr
,
element
,
separator
)
;
}
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
test/red-curtain-50x50.jpg
deleted
100644 → 0
+
0
−
0
View file @
6cf5269b
1.95 KiB
This diff is collapsed.
Click to expand it.
test/test-element-attributes-markdown.html
+
5
−
7
View file @
d844195b
...
...
@@ -22,9 +22,7 @@
<!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n"></section> -->
<!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
<section
data-markdown
data-separator=
"^\n---\n$"
data-vertical=
"^\n--\n$"
data-element-attributes=
"{_\s*?([^}]+?)}"
>
<section
data-markdown
data-separator=
"^\n---\n$"
data-vertical=
"^\n--\n$"
>
<script
type=
"text/template"
>
##
Slide
1.1
{
_class
=
"
fragment fade-out
"
data
-
fragment
-
index
=
"
1
"
}
...
...
@@ -60,10 +58,10 @@
-
list
item
3
{
_class
=
"
fragment highlight-green
"
}
-
list
item
4
{
_class
=
"
fragment highlight-green
"
}
-
list
item
5
{
_class
=
"
fragment highlight-green
"
}
Test
!
[
Example
Picture
{
_class
=
"
reveal stretch
"
}](
red
-
curtain
-
50
x50
.
jp
g
)
Test
!
[
Example
Picture
{
_class
=
"
reveal stretch
"
}](
assets
/
image2
.
pn
g
)
</script>
</section>
...
...
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