Commit 7e0439bc authored by guerler's avatar guerler
Browse files

Avoid using deep, add rule to markdown composable instead

parent 31be5d4d
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ async function toggleBookmark() {
    bookmarkLoading.value = false;
}

const { renderMarkdown } = useMarkdown({ openLinksInNewPage: true });
const { renderMarkdown } = useMarkdown({ noMargin: true, openLinksInNewPage: true });

/**
 * Helper functions for generating consistent element IDs
@@ -747,12 +747,6 @@ function onKeyDown(event: KeyboardEvent) {
            text-overflow: unset;
        }

        .g-card-description {
            :deep(p) {
                margin-bottom: 0;
            }
        }

        .g-card-secondary-action-label {
            @container g-card (max-width: #{$breakpoint-sm}) {
                display: none;
+15 −0
Original line number Diff line number Diff line
@@ -69,6 +69,16 @@ function addRuleHeadingIncreaseLevel(engine: MarkdownIt, increaseBy: number) {
    };
}

function addRuleNoMargin(engine: MarkdownIt) {
    engine.renderer.rules.paragraph_open = function (tokens, idx, options, env, self) {
        const token = tokens[idx];
        if (token) {
            token.attrPush(["style", "margin:0"]);
        }
        return self.renderToken(tokens, idx, options);
    };
}

/**
 * Add a rule that removes newlines after list items.
 */
@@ -138,6 +148,7 @@ interface UseMarkdownOptions {
    openLinksInNewPage?: boolean;
    increaseHeadingLevelBy?: number;
    removeNewlinesAfterList?: boolean;
    noMargin?: boolean;
}

type RawMarkdown = string;
@@ -155,6 +166,10 @@ export function useMarkdown(options: UseMarkdownOptions = {}) {
        addRuleHeadingIncreaseLevel(mdEngine, options.increaseHeadingLevelBy);
    }

    if (options.noMargin) {
        addRuleNoMargin(mdEngine);
    }

    if (options.removeNewlinesAfterList) {
        addRuleRemoveNewlinesAfterList(mdEngine);
    }