From 3b0ea3132cee067ec19dcc3f1ca437cd859fd932 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 2 Mar 2023 11:50:24 +0100 Subject: [PATCH 1/2] #518: Fix YAML parser --- CHANGELOG.md | 2 ++ src/helpers/ArticleHelper.ts | 2 +- src/parsers/ParserEngines.ts | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b190fc22..75835f5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ ### ๐Ÿž Fixes +- [#518](https://github.com/estruyf/vscode-front-matter/issues/518): Fix an issue where the `YAML` parser adds line breaks to long strings + ## [8.3.0] - 2022-02-14 - [Release notes](https://beta.frontmatter.codes/updates/v8.3.0) ### ๐Ÿงช Experimental features diff --git a/src/helpers/ArticleHelper.ts b/src/helpers/ArticleHelper.ts index 11d045a3..46624367 100644 --- a/src/helpers/ArticleHelper.ts +++ b/src/helpers/ArticleHelper.ts @@ -203,7 +203,7 @@ export class ArticleHelper { noArrayIndent: !indentArray, skipInvalid: true, noCompatMode: true, - lineWidth: 500, + lineWidth: 50000, indent: spaces || 2 } as DumpOptions as any); } diff --git a/src/parsers/ParserEngines.ts b/src/parsers/ParserEngines.ts index d8b82ce9..6003ce49 100644 --- a/src/parsers/ParserEngines.ts +++ b/src/parsers/ParserEngines.ts @@ -1,4 +1,5 @@ import * as yaml from 'yaml'; +import * as jsyaml from 'js-yaml'; import * as toml from '@iarna/toml'; import { Format, FrontMatterParser } from '.'; @@ -48,11 +49,12 @@ export const Engines = { } } - return docYaml.toString(); + const jsonObj = docYaml.toJSON(); + return jsyaml.dump(jsonObj, options); } } - return yaml.stringify(obj, options); + return jsyaml.dump(obj, options); } } } From 4ffcd76aac0440b9e1825176c7285dc85afde2d7 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 2 Mar 2023 11:51:05 +0100 Subject: [PATCH 2/2] Remove log --- src/panelWebView/components/CustomView/CustomView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/panelWebView/components/CustomView/CustomView.tsx b/src/panelWebView/components/CustomView/CustomView.tsx index 7bdbce76..9ac0bf73 100644 --- a/src/panelWebView/components/CustomView/CustomView.tsx +++ b/src/panelWebView/components/CustomView/CustomView.tsx @@ -12,7 +12,6 @@ export const CustomView: React.FunctionComponent = ({ metadata const [customHtml, setCustomHtml] = useState(undefined); useEffect(() => { - console.log(window.fmExternal) if (window.fmExternal && window.fmExternal.getPanelView) { window.fmExternal.getPanelView(metadata).then((viewDetails: CustomPanelViewResult | undefined) => { if (viewDetails && viewDetails.title && viewDetails.content) {