Retain carriage in codec-json
MODIFY
packages/@romejs/codec-json/parse.ts
packages/@romejs/codec-json/parse.ts
@@ -115,7 +115,11 @@ export default createParser(
void
> {
constructor(opts: JSONParserOptions) {
- super(opts, 'parse/json');
+ super({
+ ...opts,
+ retainCarriageReturn: true,
+ }, 'parse/json');
+
this.options = opts;
this.ignoreWhitespaceTokens = true;

MODIFY
packages/@romejs/codec-json/types.ts
packages/@romejs/codec-json/types.ts
@@ -14,7 +14,7 @@ import {
import {ConsumeContext} from '@romejs/consume';
import {DiagnosticCategory} from '@romejs/diagnostics';
-export type JSONParserOptions = ParserOptions & {
+export type JSONParserOptions = Omit<ParserOptions, 'retainCarriageReturn'> & {
consumeDiagnosticCategory?: DiagnosticCategory;
};

MODIFY
packages/@romejs/core/test-worker/TestWorkerRunner.ts
packages/@romejs/core/test-worker/TestWorkerRunner.ts
@@ -34,7 +34,7 @@ import {
convertTransportFileReference,
} from '../common/types/files';
import {createAbsoluteFilePath, AbsoluteFilePath} from '@romejs/path';
-import {markup} from '@romejs/string-markup';
+import {markup, escapeMarkup} from '@romejs/string-markup';
const MAX_RUNNING_TESTS = 20;
@@ -177,7 +177,7 @@ export default class TestWorkerRunner {
let diagnostic: Diagnostic = deriveDiagnosticFromError({
error: opts.error,
category: 'tests/failure',
- label: testName,
+ label: escapeMarkup(testName),
filename,
cleanFrames(frames) {
// TODO we should actually get the frames before module init and do it that way

MODIFY
packages/@romejs/parser-core/index.ts
packages/@romejs/parser-core/index.ts
@@ -48,6 +48,7 @@ import {removeCarriageReturn} from '@romejs/string-utils';
export * from './types';
export type ParserOptions = {
+ retainCarriageReturn?: boolean;
path?: string | UnknownFilePath;
mtime?: number;
input?: string;
@@ -108,8 +109,11 @@ type ParserSnapshot<Tokens extends TokensShape, State> = {
function normalizeInput(opts: ParserOptions): string {
const {input} = opts;
+
if (input === undefined) {
return '';
+ } else if (opts.retainCarriageReturn) {
+ return input;
} else {
return removeCarriageReturn(input);
}

Retain carriage in codec-json