Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JUNCA24 RevealJS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
PGI15-Teaching
JUNCA24 RevealJS
Commits
dd9fa3e2
Commit
dd9fa3e2
authored
11 years ago
by
VonC
Browse files
Options
Downloads
Patches
Plain Diff
First refactoring
parent
3d2549d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugin/markdown/markdown.js
+32
-11
32 additions, 11 deletions
plugin/markdown/markdown.js
test/test-markdown-attributes.html
+1
-1
1 addition, 1 deletion
test/test-markdown-attributes.html
test/test-markdown-element-attributes.html
+2
-2
2 additions, 2 deletions
test/test-markdown-element-attributes.html
with
35 additions
and
14 deletions
plugin/markdown/markdown.js
+
32
−
11
View file @
dd9fa3e2
...
...
@@ -323,33 +323,50 @@
while
(
matchesClass
=
mardownClassRegex
.
exec
(
classes
)
)
{
elementTarget
.
setAttribute
(
matchesClass
[
1
],
matchesClass
[
2
]
);
}
return
true
;
}
return
false
;
}
/**
* Add attributes to the parent element of a text node,
* or the element of an attribute node.
*/
function
addAttributes
(
element
,
separator
)
{
function
addAttributes
(
section
,
element
,
previousElement
,
separatorElementAttributes
,
separatorSectionAttributes
)
{
if
(
element
.
childNodes
.
length
>
0
)
{
console
.
log
(
"
element='
"
+
element
.
innerHTML
+
"
', nodeType='
"
+
element
.
nodeType
+
"
'
"
);
console
.
log
(
"
previousElement=
"
+
previousElement
)
console
.
log
(
"
section=****
"
+
section
.
outerHTML
+
"
****
"
);
if
(
element
!=
null
&&
element
.
childNodes
!=
undefined
&&
element
.
childNodes
.
length
>
0
)
{
previousParentElement
=
element
;
for
(
var
i
=
0
;
i
<
element
.
childNodes
.
length
;
i
++
)
{
addAttributes
(
element
.
childNodes
[
i
],
separator
);
childElement
=
element
.
childNodes
[
i
];
console
.
log
(
"
Child element='
"
+
childElement
.
innerHTML
+
"
'
"
);
if
(
i
>
0
)
{
previousParentElement
=
element
.
childNodes
[
i
-
1
];
}
parentSection
=
section
;
if
(
childElement
.
nodeName
==
"
section
"
)
{
parentSection
=
childElement
;
previousParentElement
=
childElement
;
}
addAttributes
(
parentSection
,
childElement
,
previousParentElement
,
separatorElementAttributes
,
separatorSectionAttributes
);
}
}
var
nodeValue
;
var
elementTarget
;
if
(
element
.
nodeType
==
Node
.
COMMENT_NODE
)
{
if
(
addAttributeInElement
(
element
,
previousElement
,
separatorElementAttributes
)
==
false
)
{
addAttributeInElement
(
element
,
section
,
separatorSectionAttributes
);
}
}
// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
if
(
element
.
nodeType
==
Node
.
TEXT_NODE
&&
/
\S
/
.
test
(
element
.
nodeValue
)
)
{
addAttributeInElement
(
element
,
element
.
parentNode
,
separator
);
addAttributeInElement
(
element
,
element
.
parentNode
,
separator
ElementAttributes
);
}
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
);
addAttributeInElement
(
attr
,
element
,
separator
ElementAttributes
);
}
}
...
...
@@ -376,9 +393,13 @@
var
markdown
=
getMarkdownFromSlide
(
section
);
section
.
innerHTML
=
marked
(
markdown
);
addAttributes
(
section
,
section
.
getAttribute
(
'
data-element-attributes
'
)
||
//console.log("markdown="+markdown);
addAttributes
(
section
,
section
,
null
,
section
.
getAttribute
(
'
data-element-attributes
'
)
||
section
.
parentNode
.
getAttribute
(
'
data-element-attributes
'
)
||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR
);
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR
,
section
.
getAttribute
(
'
data-attributes
'
)
||
section
.
parentNode
.
getAttribute
(
'
data-attributes
'
)
||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR
);
// If there were notes, we need to re-add them after
// having overwritten the section's HTML
...
...
This diff is collapsed.
Click to expand it.
test/test-markdown-attributes.html
+
1
−
1
View file @
dd9fa3e2
...
...
@@ -15,7 +15,7 @@
<div
id=
"qunit"
></div>
<div
id=
"qunit-fixture"
></div>
<div
class=
"reveal"
style=
"display:
non
e;"
>
<div
class=
"reveal"
style=
"display:
tru
e;"
>
<div
class=
"slides"
>
...
...
This diff is collapsed.
Click to expand it.
test/test-markdown-element-attributes.html
+
2
−
2
View file @
dd9fa3e2
...
...
@@ -15,7 +15,7 @@
<div
id=
"qunit"
></div>
<div
id=
"qunit-fixture"
></div>
<div
class=
"reveal"
style=
"display:
non
e;"
>
<div
class=
"reveal"
style=
"display:
tru
e;"
>
<div
class=
"slides"
>
...
...
@@ -44,7 +44,7 @@
##
Slide
2
Paragraph
1.2
Paragraph
1.2
multi
-
line
{
_class
=
"
fragment highlight-red
"
}
Paragraph
2.2
{
_class
=
"
fragment highlight-red
"
}
...
...
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