Skip to content

Commit

Permalink
docs(preview): improve jsdocs for markdownit preview plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Mar 19, 2024
1 parent 0969f2b commit 6fe12c9
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/markdownit/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
*/

/**
*
* @param tokens
* @param i
* Check if the given tokens represent a preview in a paragraph
* @param {Array} tokens - tokens to check
* @param {number} i - offset into the tokens
*/
function isPreviewLinkInParagraph(tokens, i) {
const [prev, cur, next] = tokens.slice(i - 1, i + 2)
Expand All @@ -38,15 +38,11 @@ function isPreviewLinkInParagraph(tokens, i) {
&& next.type === 'paragraph_close'
}

/* Remove wrapping tokens
*
* @param {array} tokens - the token stream to modify
* @param {Number} i - index of the token to unwrap
*/
/**
* Remove wrapping tokens
*
* @param tokens
* @param i
* @param {Array} tokens - the token stream to modify
* @param {number} i - index of the token to unwrap
*/
function unwrapToken(tokens, i) {
// Start from the end so indexes stay the same.
Expand All @@ -60,9 +56,10 @@ function unwrapToken(tokens, i) {
export default (md) => {

/**
* Markdownit plugin to unwrap previews from a paragraph
*
* @param root0
* @param root0.tokens
* @param {object} state handed to the plugin
* @param {Array} state.tokens current token stream
*/
function linkPreviews({ tokens }) {
// do not process first and last token
Expand Down

0 comments on commit 6fe12c9

Please sign in to comment.