Skip to content

Commit a0344f4

Browse files
committed
Update
1 parent e70f1a9 commit a0344f4

File tree

6 files changed

+231
-198
lines changed

6 files changed

+231
-198
lines changed

CommonMarkdown.swift.xcworkspace/contents.xcworkspacedata

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0600"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "EBDDF16619BA1BD8005F2E06"
18+
BuildableName = "CommonMark.framework"
19+
BlueprintName = "CommonMark"
20+
ReferencedContainer = "container:CommonMark.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
27+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28+
shouldUseLaunchSchemeArgsEnv = "YES"
29+
buildConfiguration = "Debug">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "EBDDF17119BA1BD8005F2E06"
36+
BuildableName = "CommonMarkTests.xctest"
37+
BlueprintName = "CommonMarkTests"
38+
ReferencedContainer = "container:CommonMark.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
<MacroExpansion>
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "EBDDF16619BA1BD8005F2E06"
46+
BuildableName = "CommonMark.framework"
47+
BlueprintName = "CommonMark"
48+
ReferencedContainer = "container:CommonMark.xcodeproj">
49+
</BuildableReference>
50+
</MacroExpansion>
51+
</TestAction>
52+
<LaunchAction
53+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
54+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
55+
launchStyle = "0"
56+
useCustomWorkingDirectory = "NO"
57+
buildConfiguration = "Debug"
58+
ignoresPersistentStateOnLaunch = "NO"
59+
debugDocumentVersioning = "YES"
60+
allowLocationSimulation = "YES">
61+
<MacroExpansion>
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "EBDDF16619BA1BD8005F2E06"
65+
BuildableName = "CommonMark.framework"
66+
BlueprintName = "CommonMark"
67+
ReferencedContainer = "container:CommonMark.xcodeproj">
68+
</BuildableReference>
69+
</MacroExpansion>
70+
<AdditionalOptions>
71+
</AdditionalOptions>
72+
</LaunchAction>
73+
<ProfileAction
74+
shouldUseLaunchSchemeArgsEnv = "YES"
75+
savedToolIdentifier = ""
76+
useCustomWorkingDirectory = "NO"
77+
buildConfiguration = "Release"
78+
debugDocumentVersioning = "YES">
79+
<MacroExpansion>
80+
<BuildableReference
81+
BuildableIdentifier = "primary"
82+
BlueprintIdentifier = "EBDDF16619BA1BD8005F2E06"
83+
BuildableName = "CommonMark.framework"
84+
BlueprintName = "CommonMark"
85+
ReferencedContainer = "container:CommonMark.xcodeproj">
86+
</BuildableReference>
87+
</MacroExpansion>
88+
</ProfileAction>
89+
<AnalyzeAction
90+
buildConfiguration = "Debug">
91+
</AnalyzeAction>
92+
<ArchiveAction
93+
buildConfiguration = "Release"
94+
revealArchiveInOrganizer = "YES">
95+
</ArchiveAction>
96+
</Scheme>

CommonMarkdown/specs/gentests.pl

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env perl
2+
use warnings;
3+
use strict;
4+
use IO::Handle;
5+
6+
my $SPEC = shift @ARGV;
7+
8+
# Markdown implementations vary on insignificant whitespace.
9+
# Some leave blanks between block elements, others don't.
10+
# This function tries to normalize the output so it can be
11+
# compared with our test. tidy takes two arguments: the
12+
# string containing the actual output, and a pathname of the
13+
# file to which the tidied output is to be saved.
14+
sub tidy
15+
{
16+
my $inpre = 0;
17+
my $out = "";
18+
my $outfh;
19+
open($outfh, '>', \$out);
20+
for (split /^/, $_[0]) {
21+
if (/<pre/) {
22+
$inpre = 1;
23+
} elsif (/<\/pre/) {
24+
$inpre = 0;
25+
}
26+
if ($inpre) {
27+
print $outfh $_;
28+
} else {
29+
# remove leading spaces
30+
s/^ *//;
31+
# remove trailing spaces
32+
s/ *$//;
33+
# collapse consecutive spaces
34+
s/ */ /;
35+
# collapse space before /> in tag
36+
s/ *\/>/\/>/;
37+
# skip blank line
38+
if (/^$/) {
39+
next;
40+
}
41+
print $outfh $_;
42+
}
43+
}
44+
close $outfh;
45+
return $out;
46+
}
47+
48+
sub writetest
49+
{
50+
my $markdown = $_[0];
51+
my $html = $_[1];
52+
my $testname = $_[2];
53+
my $actual = "";
54+
# We use → to indicate tab and ␣ space in the spec
55+
$markdown =~ s//\t/g;s// /g;
56+
$html =~ s//\t/g;s// /g;
57+
# $html = &tidy($html);
58+
59+
$markdown =~ s/\\/\\\\/g;
60+
$markdown =~ s/\n/\\n/g;
61+
$markdown =~ s/"/\\"/g;
62+
$markdown =~ s/\t/\\t/g;
63+
$html =~ s/\\/\\\\/g;
64+
$html =~ s/\n/\\n/g;
65+
$html =~ s/\"/\\"/g;
66+
67+
print "\n func $testname() {";
68+
print "\n XCTAssertEqual(HTMLRenderer().renderBlock(parse(\"${markdown}\")), \"${html}\", \"Source:\\n\\n${markdown}\\n\")";
69+
print "\n }\n\n";
70+
}
71+
72+
my $stage = 0;
73+
my $markdown = "";
74+
my $html = "";
75+
my $example = 0;
76+
my $linenum = 0;
77+
my $exampleline = 0;
78+
my @secnums = ();
79+
my $secheading;
80+
my $firstsection = 1;
81+
82+
print "//Autogenerated code. Do not change.\n\nimport CommonMarkdown\nimport XCTest\n\n";
83+
84+
open(SPEC, "< $SPEC");
85+
while (<SPEC>) {
86+
$linenum++;
87+
if (/^\.$/) {
88+
$stage = ($stage + 1) % 3;
89+
if ($stage == 1) {
90+
$exampleline = $linenum;
91+
}
92+
if ($stage == 0) {
93+
$example++;
94+
writetest($markdown, $html, "testExample${example}FromLine$exampleline");
95+
$markdown = "";
96+
$html = "";
97+
}
98+
} elsif ($stage == 0 && $_ =~ /^<!-- END TESTS -->/) {
99+
last;
100+
} elsif ($stage == 0 && $_ =~ /^(#+) +(.*)/) {
101+
my $seclevel = length($1);
102+
$secheading = $2;
103+
if ($#secnums == $seclevel - 1) {
104+
$secnums[$#secnums]++;
105+
} elsif ($#secnums > $seclevel - 1) {
106+
@secnums = @secnums[0..($seclevel - 1)];
107+
$secnums[$#secnums]++;
108+
} else {
109+
while ($#secnums < $seclevel - 1) {
110+
push(@secnums, 1);
111+
}
112+
}
113+
114+
if ($firstsection == 0) {
115+
print "}\n\n";
116+
}
117+
$firstsection = 0;
118+
119+
$secheading =~ s/\W/_/g;
120+
print ("\n", "class Section_" . join("_", @secnums) . "_" . $secheading, " : XCTestCase {\n");
121+
} elsif ($stage == 1) {
122+
$markdown .= $_;
123+
} elsif ($stage == 2) {
124+
$html .= $_;
125+
}
126+
}
127+
128+
print "}";
129+
130+
exit 0

0 commit comments

Comments
 (0)