mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 06:43:15 +00:00
parent
29606c6d24
commit
2e51f08bef
|
@ -35,6 +35,14 @@ ElementWidget.prototype.render = function(parent,nextSibling) {
|
||||||
if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {
|
if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {
|
||||||
tag = "safe-" + tag;
|
tag = "safe-" + tag;
|
||||||
}
|
}
|
||||||
|
// Adjust headings by the current base level
|
||||||
|
var headingLevel = ["h1","h2","h3","h4","h5","h6"].indexOf(tag);
|
||||||
|
if(headingLevel !== -1) {
|
||||||
|
var baseLevel = parseInt(this.getVariable("tv-adjust-heading-level","0"),10) || 0;
|
||||||
|
headingLevel = Math.min(Math.max(headingLevel + 1 + baseLevel,1),6);
|
||||||
|
tag = "h" + headingLevel;
|
||||||
|
}
|
||||||
|
// Create the DOM node
|
||||||
var domNode = this.document.createElementNS(this.namespace,tag);
|
var domNode = this.document.createElementNS(this.namespace,tag);
|
||||||
this.assignAttributes(domNode,{excludeEventAttributes: true});
|
this.assignAttributes(domNode,{excludeEventAttributes: true});
|
||||||
parent.insertBefore(domNode,nextSibling);
|
parent.insertBefore(domNode,nextSibling);
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
created: 20180609112450207
|
||||||
|
modified: 20180609112450207
|
||||||
|
title: Sample Headings 1,2,3
|
||||||
|
|
||||||
|
! This is a Level 1 Heading
|
||||||
|
|
||||||
|
This is a paragraph.
|
||||||
|
|
||||||
|
<$vars tv-adjust-heading-level="-2">
|
||||||
|
|
||||||
|
{{Sample Headings 3,4,5}}
|
||||||
|
|
||||||
|
</$vars>
|
||||||
|
|
||||||
|
!! This is a Level 2 heading
|
||||||
|
|
||||||
|
<$vars tv-adjust-heading-level="-1">
|
||||||
|
|
||||||
|
{{Sample Headings 4,5,6}}
|
||||||
|
|
||||||
|
</$vars>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
created: 20180609112450207
|
||||||
|
modified: 20180609112450207
|
||||||
|
title: Sample Headings 3,4,5
|
||||||
|
|
||||||
|
!!! This is written as a Level 3 heading
|
||||||
|
|
||||||
|
!!!! This is written as a Level 4 heading
|
||||||
|
|
||||||
|
!!!!! This is written as a Level 5 heading
|
|
@ -0,0 +1,9 @@
|
||||||
|
created: 20180609112450207
|
||||||
|
modified: 20180609112450207
|
||||||
|
title: Sample Headings 4,5,6
|
||||||
|
|
||||||
|
!!!! This is written as a Level 4 heading
|
||||||
|
|
||||||
|
!!!!! This is written as a Level 5 heading
|
||||||
|
|
||||||
|
!!!!!! This is written as a Level 6 heading
|
|
@ -0,0 +1,25 @@
|
||||||
|
created: 20180609112450207
|
||||||
|
modified: 20180609112450207
|
||||||
|
tags: [[tv-adjust-heading-level Variable]] [[Variable Examples]]
|
||||||
|
title: tv-adjust-heading-level Variable (Examples)
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
\define show-tiddler(title)
|
||||||
|
!! $title$
|
||||||
|
|
||||||
|
<$codeblock code={{$title$}}/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
! Tiddlers
|
||||||
|
|
||||||
|
<<show-tiddler "Sample Headings 1,2,3">>
|
||||||
|
|
||||||
|
<<show-tiddler "Sample Headings 3,4,5">>
|
||||||
|
|
||||||
|
<<show-tiddler "Sample Headings 4,5,6">>
|
||||||
|
|
||||||
|
! Example
|
||||||
|
|
||||||
|
<$macrocall $name=".example" n="1"
|
||||||
|
eg="""<$transclude tiddler="Sample Headings 1,2,3" mode="block"/>"""/>
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
caption: tv-adjust-heading-level
|
||||||
|
created: 20180609112450207
|
||||||
|
modified: 20180609112450207
|
||||||
|
tags: Variables [[Core Variables]] [[Configuration Variables]]
|
||||||
|
title: tv-adjust-heading-level Variable
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
The <<.def tv-adjust-heading-level>> [[variable|Variables]] allows the level of [[headings|Headings in WikiText]] to be adjusted. It is interpreted as a positive or negative number (e.g. "2" or "-3") that is added to the heading level for display.
|
||||||
|
|
||||||
|
Note that if the resulting heading level is less than 1 then level 1 is used instead. This means that specfiying a large negative adjustment factor will reset all headings to display as level 1. Similarly, heading levels larger than 6 are clamped to the maximum HTML heading level of 6.
|
||||||
|
|
||||||
|
<<.variable-examples "tv-adjust-heading-level">>
|
Loading…
Reference in New Issue
Block a user