General document functions
- Source:
- document.js
Properties:
| Name | Type | Description |
|---|---|---|
headers |
array | Array of header elements in document |
dimensions |
object | visible document height and width, taking into account the CriticMarkup and Search bars. |
Members
-
init
-
Initialize document and store headers array and inital window dimensions
- Source:
- document.js
Methods
-
allHeaders()
-
Return an array of all headers in the document
- Source:
- document.js
Returns:
Array of h1-h6 header DOM elements
- Type
- Array
Example
Marked.document.allHeaders()
-
countHeaders(level)
-
Counts the number of headers.
Parameters:
Name Type Description levelString | Array Header level(s) to check
- Source:
- document.js
Returns:
Number of headers.
- Type
- Number
Examples
Marked.document.countHeaders('2')Marked.document.countHeaders([4,5])
-
dimLinks( [flag])
-
Toggle removal of link highlight styles
Parameters:
Name Type Argument Description flagboolean <optional>
Force link highlights on or off (true or false), empty toggles state
- Source:
- document.js
Example
Marked.document.dimLinks(true);
-
getBase()
-
Gets the base url
- Source:
- document.js
Returns:
The base url.
- Type
- String
Example
Marked.document.getBase()
-
getHTML()
-
Gets the live html from the DOM
- Source:
- document.js
Returns:
The live html.
- Type
- string
Example
Marked.document.getHTML()
-
getHead()
-
Gets the live head content from the DOM
- Source:
- document.js
Returns:
The live head content.
- Type
- string
Example
Marked.document.getHead()
-
headerSubset(a, b)
-
Retrieve a subset of headers wihin a range
Parameters:
Name Type Description aNumber top limit [1-6]
bNumber bottom limit [1-6]
- Source:
- document.js
Returns:
Array of headers within the given range (in document order)
- Type
- Array
Examples
Marked.document.headerSubset(1,3);
Marked.document.headerSubset()
-
hideBacklinks()
-
Hide backlinks section
- Source:
- document.js
-
highlightAvoid(wordArray, options)
-
Highlight avoid words with specified options
Parameters:
Name Type Description wordArrayArray | String Array of words to highlight or JSON string
optionsObject Highlight options
Properties
Name Type Argument Description typeString <optional>
Type of highlight to apply
latinBoolean <optional>
Whether to use Latin word boundaries
data* <optional>
Additional data for highlighting
- Source:
- document.js
Example
Marked.document.highlightAvoid(wordArray, {type: 'mkavoid', latin: true}) -
highlightAvoidWords(bool, wordArray, options)
-
Highlight avoid words
Parameters:
Name Type Description boolBoolean The bool
wordArrayArray The word array
optionsObject The options
- Source:
- document.js
Example
Marked.document.highlightAvoidWords(true)
-
highlightErrors(bool)
-
Highlight errors
Parameters:
Name Type Description boolboolean show (true) or hide (false)
- Source:
- document.js
Returns:
result
- Type
- boolean
Example
Marked.document.highlightErrors(true)
-
nearestVisibleHeadline(el)
-
If the specified jQuery object isn't visible, find the first preceding headline element that is
Parameters:
Name Type Description eljQuery jQuery element to test
- Source:
- document.js
Returns:
Either the original element or first visible preceding headline
- Type
- jQuery
Example
Marked.document.nearestVisibleHeadline($el)
-
scrollToDiff()
-
Scroll to diff marker
- Source:
- document.js
Example
Marked.document.scrollToDiff()
-
setBase( [url])
-
Sets the
URL Parameters:
Name Type Argument Description urlstring <optional>
The new url
- Source:
- document.js
Returns:
final url
- Type
- string
Example
Marked.document.setBase('https://markedapp.com') -
showBacklinks(backlinks)
-
Show backlinks in the sidebar
Parameters:
Name Type Description backlinksObject Backlinks data from Objective-C
- Source:
- document.js
-
showComments()
-
Hide or show comments based on configuration setting
- Source:
- document.js
Example
Marked.document.showComments(true);
-
showElementWithId(id, hide)
-
Shows the element with identifier.
Parameters:
Name Type Description idstring The identifier
hideboolean hide (false) or show (true)
- Source:
- document.js
Example
Marked.document.showElementWithId('firstdiff', false) -
toggleComments()
-
Toggle all comment visibility
- Source:
- document.js
Example
Marked.document.toggleComments(true);
-
toggleCriticComments( [flag])
-
Toggle CriticMarkup comment visibility
Parameters:
Name Type Argument Description flagboolean <optional>
Force CriticMarkup comments on or off (true or false), empty toggles state
- Source:
- document.js
Example
Marked.document.toggleCriticComments(true);
-
toggleFountainComments( [flag])
-
Toggle Fountain comment visibility
Parameters:
Name Type Argument Description flagboolean <optional>
Force Fountain comments on or off (true or false), empty toggles state
- Source:
- document.js
Example
Marked.document.toggleFountainComments(true);
-
toggleScrivenerComments( [flag])
-
Toggle Scrivener comment visibility
Parameters:
Name Type Argument Description flagboolean <optional>
Force Scrivener comments on or off (true or false), empty toggles state
- Source:
- document.js
Example
Marked.document.toggleScrivenerComments(true)
-
unhighlightAvoid( [hltype])
-
Unhighlight avoid words
Parameters:
Name Type Argument Description hltypeString <optional>
The highlight type to unhighlight
- Source:
- document.js
Example
Marked.document.unhighlightAvoid('mkavoid') -
updateHeaderIds()
-
Update h1-h6 with compatible identifiers
- Source:
- document.js
Example
Marked.document.updateHeaderIds()
-
updateWindowDimensions()
-
Store visible document height and width, taking into account the CriticMarkup and Search bars. Properties are stored in Marked.document.dimensions
- Source:
- document.js
Example
Marked.document.updateWindowDimensions()