Skip to content

Commit 2855d0a

Browse files
committed
JSON --by-file, filename can have ', YAML can have " #897, #898
1 parent c6aeb5e commit 2855d0a

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

Unix/cloc

+4-2
Original file line numberDiff line numberDiff line change
@@ -4805,9 +4805,11 @@ sub generate_report { # {{{1
48054805
if ($BY_FILE) {
48064806
$clean_lang_or_file = rm_leading_tempdir($lang_or_file, \%TEMP_DIR);
48074807
$clean_lang_or_file = xml_metachars($clean_lang_or_file) if $out_style eq "xml";
4808-
if ($out_style eq "json" or $out_style eq "yaml") {
4809-
# YAML, JSON do not allow protected characters in keys
4808+
if ($out_style eq "yaml") {
4809+
# YAML does not allow protected single quotes in keys
48104810
$clean_lang_or_file =~ s/'/0x27/g;
4811+
} elsif ($out_style eq "json") {
4812+
# JSON does not allow protected double quotes in keys
48114813
$clean_lang_or_file =~ s/"/0x2b/g;
48124814
} elsif ($out_style ne "txt") {
48134815
# text output is allowed to keep its quotes as they are

cloc

+4-2
Original file line numberDiff line numberDiff line change
@@ -4797,9 +4797,11 @@ sub generate_report { # {{{1
47974797
if ($BY_FILE) {
47984798
$clean_lang_or_file = rm_leading_tempdir($lang_or_file, \%TEMP_DIR);
47994799
$clean_lang_or_file = xml_metachars($clean_lang_or_file) if $out_style eq "xml";
4800-
if ($out_style eq "json" or $out_style eq "yaml") {
4801-
# YAML, JSON do not allow protected characters in keys
4800+
if ($out_style eq "yaml") {
4801+
# YAML does not allow protected single quotes in keys
48024802
$clean_lang_or_file =~ s/'/0x27/g;
4803+
} elsif ($out_style eq "json") {
4804+
# JSON does not allow protected double quotes in keys
48034805
$clean_lang_or_file =~ s/"/0x2b/g;
48044806
} elsif ($out_style ne "txt") {
48054807
# text output is allowed to keep its quotes as they are
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
id: 5dc174fcf86c76b9248c6eb3
3+
title: Step 3
4+
challengeType: 0
5+
dashedName: step-2
6+
demoType: onLoad ---
7+
8+
# --description--
9+
10+
In this workshop, you will learn how to work with basic HTML elements like
11+
headings.
12+

tests/outputs/issues/898/results.yaml

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
header :
44
cloc_url : github.com/AlDanial/cloc
55
cloc_version : 2.05
6-
elapsed_seconds : 0.00426006317138672
7-
n_files : 2
8-
n_lines : 24
9-
files_per_second : 469.476606223416
10-
lines_per_second : 5633.71927468099
6+
elapsed_seconds : 0.00424814224243164
7+
n_files : 3
8+
n_lines : 36
9+
files_per_second : 706.191042765743
10+
lines_per_second : 8474.29251318891
1111
report_file : ../../../outputs/issues/898/results.yaml
12+
'./irregular"file2.md' :
13+
blank: 3
14+
comment: 0
15+
code: 9
16+
language: Markdown
1217
'./irregular0x27file.md' :
1318
blank: 3
1419
comment: 0
@@ -20,7 +25,7 @@ header :
2025
code: 9
2126
language: Markdown
2227
SUM:
23-
blank: 6
28+
blank: 9
2429
comment: 0
25-
code: 18
26-
nFiles: 2
30+
code: 27
31+
nFiles: 3

0 commit comments

Comments
 (0)