Skip to content

Commit

Permalink
Remove double parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
nirname committed Jul 3, 2023
1 parent 1b190b2 commit d5021ca
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 46 deletions.
2 changes: 0 additions & 2 deletions packages/mermaid/src/diagrams/class/classRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ const insertMarkers = function (elem) {
export const draw = function (text, id, _version, diagObj) {
const conf = getConfig().class;
idCache = {};
// diagObj.db.clear();
// diagObj.parser.parse(text);

log.info('Rendering diagram ' + text);

Expand Down
7 changes: 0 additions & 7 deletions packages/mermaid/src/diagrams/er/erRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,6 @@ export const draw = function (text, id, _version, diagObj) {
: select('body');
// const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;

// Parse the text to populate erDb
// try {
// parser.parse(text);
// } catch (err) {
// log.debug('Parsing failed');
// }

// Get a reference to the svg node that contains the text
const svg = root.select(`[id='${id}']`);

Expand Down
7 changes: 0 additions & 7 deletions packages/mermaid/src/diagrams/flowchart/flowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,6 @@ export const draw = function (text, id, _version, diagObj) {
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;

// Parse the graph definition
try {
diagObj.parser.parse(text);
} catch (err) {
log.debug('Parsing failed');
}

// Fetch the default direction, use TD if none was found
let dir = diagObj.db.getDirection();
if (dir === undefined) {
Expand Down
2 changes: 0 additions & 2 deletions packages/mermaid/src/diagrams/gantt/ganttRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ let w;
export const draw = function (text, id, version, diagObj) {
const conf = getConfig().gantt;

// diagObj.db.clear();
// parser.parse(text);
const securityLevel = getConfig().securityLevel;
// Handle root and Document for when rendering in sandbox mode
let sandboxElement;
Expand Down
7 changes: 0 additions & 7 deletions packages/mermaid/src/diagrams/git/gitGraphRenderer-old.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { curveBasis, line, select } from 'd3';

import db from './gitGraphAst.js';
import gitGraphParser from './parser/gitGraph.js';
import { logger } from '../../logger.js';
import { interpolateToCurve } from '../../utils.js';

Expand Down Expand Up @@ -328,13 +327,7 @@ function renderLines(svg, commit, direction, branchColor = 0) {

export const draw = function (txt, id, ver) {
try {
const parser = gitGraphParser.parser;
parser.yy = db;
parser.yy.clear();

logger.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver);
// Parse the graph definition
parser.parse(txt + '\n');

config = Object.assign(config, apiConfig, db.getOptions());
logger.debug('effective options', config);
Expand Down
6 changes: 0 additions & 6 deletions packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,8 @@ function positionNodes(cy) {
export const draw = async (text, id, version, diagObj) => {
const conf = getConfig();

// console.log('Config: ', conf);
conf.htmlLabels = false;

// This is done only for throwing the error if the text is not valid.
diagObj.db.clear();
// Parse the graph definition
diagObj.parser.parse(text);

log.debug('Rendering mindmap diagram\n' + text, diagObj.parser);

const securityLevel = getConfig().securityLevel;
Expand Down
3 changes: 0 additions & 3 deletions packages/mermaid/src/diagrams/pie/pieRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ export const draw = (txt, id, _version, diagObj) => {
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;

// Parse the Pie Chart definition
diagObj.db.clear();
diagObj.parser.parse(txt);
log.debug('Parsed info diagram');
const elem = doc.getElementById(id);
width = elem.parentElement.offsetWidth;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ const elementString = (str) => {

export const draw = (text, id, _version, diagObj) => {
conf = getConfig().requirement;
diagObj.db.clear();
diagObj.parser.parse(text);

const securityLevel = conf.securityLevel;
// Handle root and Document for when rendering in sandbox mode
Expand Down
2 changes: 0 additions & 2 deletions packages/mermaid/src/diagrams/state/stateRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export const draw = function (text, id, _version, diagObj) {
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;

// diagObj.db.clear();
// parser.parse(text);
log.debug('Rendering diagram ' + text);

// Fetch the default direction, use TD if none was found
Expand Down
6 changes: 0 additions & 6 deletions packages/mermaid/src/diagrams/timeline/timelineRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ export const draw = function (text: string, id: string, version: string, diagObj
// @ts-expect-error - wrong config?
const LEFT_MARGIN = conf.leftMargin ?? 50;

//2. Clear the diagram db before parsing
diagObj.db.clear?.();

//3. Parse the diagram text
diagObj.parser.parse(text + '\n');

log.debug('timeline', diagObj.db);

const securityLevel = conf.securityLevel;
Expand Down
2 changes: 0 additions & 2 deletions packages/mermaid/src/diagrams/user-journey/journeyRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const conf = getConfig().journey;
const LEFT_MARGIN = conf.leftMargin;
export const draw = function (text, id, version, diagObj) {
const conf = getConfig().journey;
diagObj.db.clear();
diagObj.parser.parse(text + '\n');

const securityLevel = getConfig().securityLevel;
// Handle root and Document for when rendering in sandbox mode
Expand Down

0 comments on commit d5021ca

Please sign in to comment.