Skip to content
Browse files

Fixed conversion of single to double star within example blocks and s…

…pans under certain circumstances. Closes #77.

The problem was with appledoc treating single star as bold and single underscore as italics while Markdown treats single star or underscore as italics and double star or underscore as bold. This requires appledoc preprocessing comment text and converting any single star marker to double star. However as Markdown processor doesn't convert markers inside code blocks, this effectively changed the layout in there. To further complicate the issue, appledoc preprocessor doesn't know in advance whether certain part of text will be converted to code block or not. To compensate, appledoc now leaves original markers untouched and uses placeholder strings when converting single stars to double ones. These placeholders are caught and properly handled later on, in generated HTML where detecting code block or span is simple.
  • Loading branch information...
1 parent 72391e4 commit a85a42b4b79041a16dfa96f7f0c34a5bc28a8298 @tomaz committed Mar 14, 2011
View
25 Application/GBApplicationSettingsProvider.h
@@ -363,10 +363,20 @@ extern id kGBCustomDocumentIndexDescKey;
This should be left to default value, however it's useful to prevent embedding for unit testing.
@see stringByEmbeddingCrossReference:
+ @see embedAppledocBoldMarkersWhenProcessingMarkdown
*/
@property (assign) BOOL embedCrossReferencesWhenProcessingMarkdown;
-/** Returns a new string with the given Markdown reference embedded in special markers.
+/** Specifies whether cross references should be embedded to special strings when processing Markdown.
+
+ This should be left to default value, however it's useful to prevent embedding for unit testing.
+
+ @see stringByEmbeddingCrossReference:
+ @see embedCrossReferencesWhenProcessingMarkdown
+ */
+@property (assign) BOOL embedAppledocBoldMarkersWhenProcessingMarkdown;
+
+/** Returns a new string with the given Markdown reference embedded in special cross reference markers used for post processing.
This should be used for all generated cross references, so that we can later detect them when converting HTML with `stringByConvertingMarkdownToHTML:`.
@@ -379,6 +389,19 @@ extern id kGBCustomDocumentIndexDescKey;
*/
- (NSString *)stringByEmbeddingCrossReference:(NSString *)value;
+/** Returns a new string with the given value embedded in special bold markers used for post processing.
+
+ This should be used for all appledoc style bold markers (single star), so that we can later detect them when converting HTML with `stringByConvertingMarkdownToHTML:`.
+
+ @warning *Important:* Behavior of this method depends on `embedAppledocBoldMarkersWhenProcessingMarkdown` value. If it's `YES`, strings are embedded, otherwise value is returned without embedding.
+
+ @param value The string to embedd.
+ @return Returns embedded string.
+ @see stringByConvertingMarkdownToHTML:
+ @see embedAppledocBoldMarkersWhenProcessingMarkdown
+ */
+- (NSString *)stringByEmbeddingAppledocBoldMarkers:(NSString *)value;
+
/** Returns a new string containing HTML representation of the given Markdown string.
This is the main method for converting Markdown to HTML. It works in two phases: first the Markdown engine is asked to convert the given string to HTML, then the string is cleaned up so that it contains proper HTML code. Cleaning up phase consists of:
View
92 Application/GBApplicationSettingsProvider.m
@@ -35,6 +35,7 @@ - (NSString *)htmlReferenceForObjectFromIndex:(GBModelBase *)object;
- (NSString *)htmlReferenceForTopLevelObject:(GBModelBase *)object fromTopLevelObject:(GBModelBase *)source;
- (NSString *)htmlReferenceForMember:(id)member prefixedWith:(id)prefix;
- (NSString *)outputPathForObject:(id)object withExtension:(NSString *)extension;
+- (NSString *)stringByReplacingOccurencesOfRegex:(NSString *)regex inHTML:(NSString *)string usingBlock:(NSString *(^)(NSInteger captureCount, NSString **capturedStrings, BOOL insideCode))block;
- (NSString *)stringByNormalizingString:(NSString *)string;
@property (readonly) NSDateFormatter *yearDateFormatter;
@property (readonly) NSDateFormatter *yearToDayDateFormatter;
@@ -88,6 +89,7 @@ - (id)init {
self.prefixLocalMembersInRelatedItemsList = YES;
self.embedCrossReferencesWhenProcessingMarkdown = YES;
+ self.embedAppledocBoldMarkersWhenProcessingMarkdown = YES;
self.warnOnMissingOutputPathArgument = YES;
self.warnOnMissingCompanyIdentifier = YES;
@@ -154,7 +156,12 @@ - (void)replaceAllOccurencesOfPlaceholderStringsInSettingsValues {
- (NSString *)stringByEmbeddingCrossReference:(NSString *)value {
if (!self.embedCrossReferencesWhenProcessingMarkdown) return value;
- return [NSString stringWithFormat:@"~!@%@@!~", value];
+ return [NSString stringWithFormat:@"%@%@%@", self.commentComponents.codeSpanStartMarker, value, self.commentComponents.codeSpanEndMarker];
+}
+
+- (NSString *)stringByEmbeddingAppledocBoldMarkers:(NSString *)value {
+ if (!self.embedAppledocBoldMarkersWhenProcessingMarkdown) return value;
+ return [NSString stringWithFormat:@"%@%@%@", self.commentComponents.appledocBoldStartMarker, value, self.commentComponents.appledocBoldEndMarker];
}
- (NSString *)stringByConvertingMarkdownToHTML:(NSString *)markdown {
@@ -171,31 +178,36 @@ - (NSString *)stringByConvertingMarkdownToHTML:(NSString *)markdown {
}
mkd_cleanup(document);
- // Post process embedded cross references if needed.
- if (!self.embedCrossReferencesWhenProcessingMarkdown) return result;
- __block BOOL insideExampleBlock = NO;
- NSString *regex = @"<pre>|</pre>|~!@(.+?)@!~";
- NSString *clean = [result stringByReplacingOccurrencesOfRegex:regex usingBlock:^NSString *(NSInteger captureCount, NSString *const *capturedStrings, const NSRange *capturedRanges, volatile BOOL *const stop) {
- // Change flag when inside example block - we need to handle strings differently there!
- NSString *matchedText = capturedStrings[0];
- if ([matchedText isEqualToString:@"<pre>"]) {
- insideExampleBlock = YES;
- return matchedText;
- } else if ([matchedText isEqualToString:@"</pre>"]) {
- insideExampleBlock = NO;
+ // We should properly handle cross references: if outside example block, simply strip prexif/suffix markers, otherwise extract description from Markdown style scross reference (i.e. [description](the rest)) and only use that part.
+ if (self.embedCrossReferencesWhenProcessingMarkdown) {
+ NSString *regex = [self stringByEmbeddingCrossReference:@"(.+?)"];
+ result = [self stringByReplacingOccurencesOfRegex:regex inHTML:result usingBlock:^NSString *(NSInteger captureCount, NSString **capturedStrings, BOOL insideCode) {
+ NSString *linkText = capturedStrings[1];
+ if (!insideCode) return linkText;
+ NSArray *components = [linkText captureComponentsMatchedByRegex:self.commentComponents.markdownInlineLinkRegex];
+ if ([components count] < 1) return linkText;
+ return [components objectAtIndex:1];
+ }];
+ }
+
+ // We should properly handle Markdown bold markers (**) converted from appledoc style ones (*): if outside example block, simply strip prefix/suffix markers, otherwise convert back to single stars.
+ if (self.embedAppledocBoldMarkersWhenProcessingMarkdown) {
+ NSString *inner = [self stringByEmbeddingAppledocBoldMarkers:@"(.+?)"];
+ NSString *regex = [NSString stringWithFormat:@"\\*\\*%@\\*\\*|%@", inner, inner];
+ result = [self stringByReplacingOccurencesOfRegex:regex inHTML:result usingBlock:^NSString *(NSInteger captureCount, NSString **capturedStrings, BOOL insideCode) {
+ NSString *matchedText = capturedStrings[0];
+ if ([matchedText hasPrefix:@"**"]) {
+ NSString *formatText = capturedStrings[1];
+ if (!insideCode) return [NSString stringWithFormat:@"**%@**", formatText];
+ return [NSString stringWithFormat:@"*%@*", formatText];
+ } else {
+ return capturedStrings[2];
+ }
return matchedText;
- }
-
- // If outside example block, just return cross reference without embedded prefix and suffix!
- NSString *linkText = capturedStrings[1];
- if (!insideExampleBlock) return linkText;
-
- // If inside example block, we need to extract description from Markdown text and only use that part! If we don't match Markdown style reference, just use whole text...
- NSArray *components = [linkText captureComponentsMatchedByRegex:self.commentComponents.markdownInlineLinkRegex];
- if ([components count] < 1) return linkText;
- return [components objectAtIndex:1];
- }];
- return clean;
+ }];
+ }
+
+ return result;
}
- (NSString *)stringByConvertingMarkdownToText:(NSString *)markdown {
@@ -230,10 +242,11 @@ - (NSString *)stringByConvertingMarkdownToText:(NSString *)markdown {
return capturedStrings[2];
}];
- // Remove embedded preix/suffix if needed.
- if (!self.embedCrossReferencesWhenProcessingMarkdown) return result;
- result = [result stringByReplacingOccurrencesOfString:@"~!@" withString:@""];
- result = [result stringByReplacingOccurrencesOfString:@"@!~" withString:@""];
+ // Remove embedded preix/suffix.
+ result = [result stringByReplacingOccurrencesOfString:self.commentComponents.codeSpanStartMarker withString:@""];
+ result = [result stringByReplacingOccurrencesOfString:self.commentComponents.codeSpanEndMarker withString:@""];
+ result = [result stringByReplacingOccurrencesOfString:self.commentComponents.appledocBoldStartMarker withString:@""];
+ result = [result stringByReplacingOccurrencesOfString:self.commentComponents.appledocBoldEndMarker withString:@""];
return result;
}
@@ -249,6 +262,26 @@ - (NSString *)stringByEscapingHTML:(NSString *)string {
return result;
}
+- (NSString *)stringByReplacingOccurencesOfRegex:(NSString *)regex inHTML:(NSString *)string usingBlock:(NSString *(^)(NSInteger captureCount, NSString **capturedStrings, BOOL insideCode))block {
+ NSString *theRegex = [NSString stringWithFormat:@"<code>|</code>|%@", regex];
+ __block BOOL insideExampleBlock = NO;
+ return [string stringByReplacingOccurrencesOfRegex:theRegex usingBlock:^NSString *(NSInteger captureCount, NSString *const *capturedStrings, const NSRange *capturedRanges, volatile BOOL *const stop) {
+ // Change flag when inside example block - we need to handle strings differently there!
+ NSString *matchedText = capturedStrings[0];
+ if ([matchedText isEqualToString:@"<code>"]) {
+ insideExampleBlock = YES;
+ return matchedText;
+ } else if ([matchedText isEqualToString:@"</code>"]) {
+ insideExampleBlock = NO;
+ return matchedText;
+ }
+
+ // Invoke parent block when matched the given regex
+ NSString **strings = (NSString **)capturedStrings;
+ return block(captureCount, strings, insideExampleBlock);
+ }];
+}
+
- (NSString *)htmlReferenceNameForObject:(GBModelBase *)object {
NSParameterAssert(object != nil);
if (object.isTopLevelObject) return [self htmlReferenceForObject:object fromSource:object];
@@ -557,6 +590,7 @@ - (NSString *)versionIdentifier {
@synthesize prefixLocalMembersInRelatedItemsList;
@synthesize embedCrossReferencesWhenProcessingMarkdown;
+@synthesize embedAppledocBoldMarkersWhenProcessingMarkdown;
@synthesize createHTML;
@synthesize createDocSet;
View
12 Application/GBCommentComponentsProvider.h
@@ -169,4 +169,16 @@
/** Returns the regex containing all possible symbols for matching new lines. */
@property (readonly) NSString *newLineRegex;
+/** Our custom code span start marker. */
+@property (readonly) NSString *codeSpanStartMarker;
+
+/** Our custom code span end marker. */
+@property (readonly) NSString *codeSpanEndMarker;
+
+/** Our custom appledoc style bold start marker. */
+@property (readonly) NSString *appledocBoldStartMarker;
+
+/** Our custom appledoc style bold end marker. */
+@property (readonly) NSString *appledocBoldEndMarker;
+
@end
View
18 Application/GBCommentComponentsProvider.m
@@ -155,6 +155,24 @@ - (NSString *)nameDescriptionCaptureRegexForKeyword:(NSString *)keyword {
return [NSString stringWithFormat:@"^\\s*(\\S%@\\s+)(\\S+)\\s+(?s:(.*))", keyword];
}
+#pragma mark Custom markers
+
+- (NSString *)codeSpanStartMarker {
+ return @"~!@";
+}
+
+- (NSString *)codeSpanEndMarker {
+ return @"@!~";
+}
+
+- (NSString *)appledocBoldStartMarker {
+ return @"~!#";
+}
+
+- (NSString *)appledocBoldEndMarker {
+ return @"#!~";
+}
+
#pragma Properties
@synthesize crossReferenceMarkersTemplate;
View
43 Processing/GBCommentsProcessor.m
@@ -405,69 +405,74 @@ - (NSString *)stringByPreprocessingString:(NSString *)string withFlags:(GBProces
if ([string length] == 0) return string;
// Formatting markers are fine, except *, which should be converted to **. To simplify cross refs detection, we handle all possible formatting markers though so we can search for cross refs within "clean" formatted text, without worrying about markers interfering with search. Note that we also handle "standard" Markdown nested formats and bold markers here, so that we properly handle cross references within.
- NSString *nested = [string stringByReplacingOccurrencesOfRegex:@"(\\*__|__\\*|\\*\\*_|_\\*\\*|\\*\\*\\*|___|\\*_|_\\*)" withString:@"==!!=="];
- NSString *simplified = [nested stringByReplacingOccurrencesOfRegex:@"(__|\\*\\*)" withString:@"*"];
- NSArray *components = [simplified arrayOfDictionariesByMatchingRegex:@"(?s:(\\*|_|==!!==|`)(.*?)\\1)" withKeysAndCaptures:@"marker", 1, @"value", 2, nil];
- NSRange searchRange = NSMakeRange(0, [simplified length]);
- NSMutableString *result = [NSMutableString stringWithCapacity:[simplified length]];
+ NSArray *components = [string arrayOfDictionariesByMatchingRegex:@"(?s:(\\*__|__\\*|\\*\\*_|_\\*\\*|\\*\\*\\*|___|\\*_|_\\*|\\*\\*|__|\\*|_|==!!==|`)(.+?)\\1)" withKeysAndCaptures:@"marker", 1, @"value", 2, nil];
+ NSRange searchRange = NSMakeRange(0, [string length]);
+ NSMutableString *result = [NSMutableString stringWithCapacity:[string length]];
for (NSDictionary *component in components) {
// Find marker range within the remaining text. Note that we don't test for marker not found, as this shouldn't happen...
NSString *componentMarker = [component objectForKey:@"marker"];
NSString *componentText = [component objectForKey:@"value"];
- NSRange markerRange = [simplified rangeOfString:componentMarker options:0 range:searchRange];
+ NSRange markerRange = [string rangeOfString:componentMarker options:0 range:searchRange];
// If we skipped some text, convert all cross refs in it and append to the result.
if (markerRange.location > searchRange.location) {
NSRange skippedRange = NSMakeRange(searchRange.location, markerRange.location - searchRange.location);
- NSString *skippedText = [simplified substringWithRange:skippedRange];
+ NSString *skippedText = [string substringWithRange:skippedRange];
NSString *convertedText = [self stringByConvertingCrossReferencesInString:skippedText withFlags:flags];
[result appendString:convertedText];
}
// Convert the marker to proper Markdown style. Warn if unknown marker is found. This is just a precaution in case we change something above, but forget to update this part, shouldn't happen in released versions as it should get caught by unit tests...
GBProcessingFlag linkFlags = flags;
- NSString *markdownMarker = @"";
+ NSString *markdownStartMarker = @"";
+ NSString *markdownEndMarker = nil;
if ([componentMarker isEqualToString:@"*"]) {
GBLogDebug(@" - Found '%@' formatted as bold at %@...", [componentText normalizedDescription], self.currentSourceInfo);
- markdownMarker = @"**";
+ markdownStartMarker = [NSString stringWithFormat:@"**%@", self.components.appledocBoldStartMarker];
+ markdownEndMarker = [NSString stringWithFormat:@"%@**", self.components.appledocBoldEndMarker];
}
else if ([componentMarker isEqualToString:@"_"]) {
GBLogDebug(@" - Found '%@' formatted as italics at %@...", [componentText normalizedDescription], self.currentSourceInfo);
- markdownMarker = @"_";
+ markdownStartMarker = @"_";
}
else if ([componentMarker isEqualToString:@"`"]) {
GBLogDebug(@" - Found '%@' formatted as code at %@...", [componentText normalizedDescription], self.currentSourceInfo);
- markdownMarker = @"`";
+ markdownStartMarker = @"`";
linkFlags |= GBProcessingFlagEmbedMarkdownLink;
}
- else if ([componentMarker isEqualToString:@"==!!=="]) {
+ else if ([componentMarker isEqualToString:@"**"] || [componentMarker isEqualToString:@"__"] || [componentMarker isEqualToString:@"*_"] || [componentMarker isEqualToString:@"_*"]) {
+ GBLogDebug(@" - Found '%@' formatted as bold at %@...", [componentText normalizedDescription], self.currentSourceInfo);
+ markdownStartMarker = componentMarker;
+ }
+ else if ([componentMarker isEqualToString:@"*__"] || [componentMarker isEqualToString:@"__*"] || [componentMarker isEqualToString:@"**_"] || [componentMarker isEqualToString:@"_**"] || [componentMarker isEqualToString:@"***"] || [componentMarker isEqualToString:@"___"]) {
GBLogDebug(@" - Found '%@' formatted as italics/bold at %@...", [componentText normalizedDescription], self.currentSourceInfo);
- markdownMarker = @"***";
+ markdownStartMarker = componentMarker;
}
else if (self.settings.warnOnUnknownDirective) {
GBLogWarn(@"Unknown format marker %@ detected at %@!", componentMarker, self.currentSourceInfo);
}
+ if (!markdownEndMarker) markdownEndMarker = markdownStartMarker;
// Get formatted text, convert it's cross references and append proper format markers and string to result.
NSString *convertedText = [self stringByConvertingCrossReferencesInString:componentText withFlags:linkFlags];
- [result appendString:markdownMarker];
+ [result appendString:markdownStartMarker];
[result appendString:convertedText];
- [result appendString:markdownMarker];
+ [result appendString:markdownEndMarker];
// Prepare next search range.
NSUInteger location = markerRange.location + markerRange.length * 2 + [componentText length];
- searchRange = NSMakeRange(location, [simplified length] - location);
+ searchRange = NSMakeRange(location, [string length] - location);
}
// If there is some remaining text, process it for cross references and append to result.
- if ([simplified length] > searchRange.location) {
- NSString *remainingText = [simplified substringWithRange:searchRange];
+ if ([string length] > searchRange.location) {
+ NSString *remainingText = [string substringWithRange:searchRange];
NSString *convertedText = [self stringByConvertingCrossReferencesInString:remainingText withFlags:flags];
[result appendString:convertedText];
}
// Finally replace all embedded code span Markdown links to proper ones. Embedded links look like: `[`desc`](address)`.
- NSString *regex = @"`((?:~!@)?\\[`[^`]*`\\]\\(.+?\\)(?:@!~)?)`";
+ NSString *regex = [NSString stringWithFormat:@"`((?:%@)?\\[`[^`]*`\\]\\(.+?\\)(?:%@)?)`", self.components.codeSpanStartMarker, self.components.codeSpanEndMarker];
NSString *clean = [result stringByReplacingOccurrencesOfRegex:regex usingBlock:^NSString *(NSInteger captureCount, NSString *const *capturedStrings, const NSRange *capturedRanges, volatile BOOL *const stop) {
return capturedStrings[1];
}];
View
42 Testing/GBApplicationSettingsProviderTesting.m
@@ -468,6 +468,26 @@ - (void)testStringByConvertingMarkdownToHTML_shouldConvertEmbeddedCrossReference
assertThat(result2, is(@"<pre><code>[description](address)\n</code></pre>"));
}
+- (void)testStringByConvertingMarkdownToHTML_shouldConvertAppledocStyleBoldMarkersInText {
+ // setup
+ GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
+ // execute
+ NSString *result = [settings stringByConvertingMarkdownToHTML:@"**~!#text#!~**"];
+ // verify - Discount converts ** part, we just need to cleanup the remaining texts!
+ assertThat(result, is(@"<p><strong>text</strong></p>"));
+}
+
+- (void)testStringByConvertingMarkdownToHTML_shouldConvertAppledocStyleBoldMarkersInExampleBlock {
+ // setup
+ GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
+ // execute
+ NSString *result1 = [settings stringByConvertingMarkdownToHTML:@"\t**~!#text#!~**"];
+ NSString *result2 = [settings stringByConvertingMarkdownToHTML:@"\t**text**"];
+ // verify - Discount doesn't process text here, so we should revert to original markup!
+ assertThat(result1, is(@"<pre><code>*text*\n</code></pre>"));
+ assertThat(result2, is(@"<pre><code>**text**\n</code></pre>"));
+}
+
#pragma mark Markdown to text conversion
- (void)testStringByConvertingMarkdownToText_shouldConvertEmbeddedCrossReferencesInText {
@@ -492,6 +512,28 @@ - (void)testStringByConvertingMarkdownToText_shouldConvertEmbeddedCrossReference
assertThat(result2, is(@"\tdescription"));
}
+- (void)testStringByConvertingMarkdownToText_shouldConvertEmbeddedAppledocBoldMarkersInText {
+ // setup
+ GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
+ // execute
+ NSString *result1 = [settings stringByConvertingMarkdownToText:@"~!#text#!~"];
+ NSString *result2 = [settings stringByConvertingMarkdownToText:@"**~!#text#!~**"];
+ // verify
+ assertThat(result1, is(@"text"));
+ assertThat(result2, is(@"text"));
+}
+
+- (void)testStringByConvertingMarkdownToText_shouldConvertEmbeddedAppledocBoldMarkersInExampleBlock {
+ // setup
+ GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
+ // execute
+ NSString *result1 = [settings stringByConvertingMarkdownToText:@"\t~!#text#!~"];
+ NSString *result2 = [settings stringByConvertingMarkdownToText:@"\t**~!#text#!~**"];
+ // verify
+ assertThat(result1, is(@"\ttext"));
+ assertThat(result2, is(@"\ttext"));
+}
+
- (void)testStringByConvertingMarkdownToText_shouldConvertMarkdownReferences {
// setup
GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
View
4 Testing/GBCommentsProcessor-MarkdownTesting.m
@@ -117,7 +117,7 @@ - (void)testProcessCommentWithContextStore_markdown_shouldKeepInlineRemoteMember
[self assertComment:comment3 matchesLongDescMarkdown:@"[[Class value]](Classes/Class.html#//api/name/value)", nil];
}
-- (void)testProcessCommentWithContextStore_markdown_shouldProperlyFormatInlineLinksWithinCodeMarkers {
+- (void)testProcessCommentWithContextStore_markdown_shouldProperlyFormatInlineLinksWithinFormattingMarkers {
// setup
GBStore *store = [self storeWithDefaultObjects];
GBCommentsProcessor *processor = [self defaultProcessor];
@@ -133,7 +133,7 @@ - (void)testProcessCommentWithContextStore_markdown_shouldProperlyFormatInlineLi
// verify
[self assertComment:comment1 matchesLongDescMarkdown:@"[`Class`](Classes/Class.html)", nil];
[self assertComment:comment2 matchesLongDescMarkdown:@"[`Class(Category)`](Categories/Class(Category).html)", nil];
- [self assertComment:comment3 matchesLongDescMarkdown:@"**[Protocol](Protocols/Protocol.html)**", nil];
+ [self assertComment:comment3 matchesLongDescMarkdown:@"**~!#[Protocol](Protocols/Protocol.html)#!~**", nil];
[self assertComment:comment4 matchesLongDescMarkdown:@"_[Document](docs/Document.html)_", nil];
}
View
26 Testing/GBCommentsProcessor-PreprocessingTesting.m
@@ -32,18 +32,18 @@ @implementation GBCommentsProcessorPreprocessingTesting
#pragma mark Formatting markers conversion
-- (void)testStringByPreprocessingString_shouldHandleBoldMarkers {
+- (void)testStringByPreprocessingString_shouldConvertAppledocBoldMarkersToTemporarySyntax {
// setup
GBCommentsProcessor *processor = [self defaultProcessor];
// execute
NSString *result1 = [processor stringByPreprocessingString:@"*bold1* *bold text* * bolder text *" withFlags:0];
NSString *result2 = [processor stringByPreprocessingString:@"*bold1* Middle *bold text*" withFlags:0];
// verify
- assertThat(result1, is(@"**bold1** **bold text** ** bolder text **"));
- assertThat(result2, is(@"**bold1** Middle **bold text**"));
+ assertThat(result1, is(@"**~!#bold1#!~** **~!#bold text#!~** **~!# bolder text #!~**"));
+ assertThat(result2, is(@"**~!#bold1#!~** Middle **~!#bold text#!~**"));
}
-- (void)testStringByPreprocessingString_shouldHandleItalicsMarkers {
+- (void)testStringByPreprocessingString_shouldLeaveItalicsMarkers {
// setup
GBCommentsProcessor *processor = [self defaultProcessor];
// execute
@@ -54,13 +54,13 @@ - (void)testStringByPreprocessingString_shouldHandleItalicsMarkers {
assertThat(result2, is(@"_bold1_ Middle _bold text_"));
}
-- (void)testStringByPreprocessingString_shouldHandleBoldItalicsMarkers {
+- (void)testStringByPreprocessingString_shouldLeaveBoldItalicsMarkers {
// setup
GBCommentsProcessor *processor = [self defaultProcessor];
// execute
NSString *result = [processor stringByPreprocessingString:@"_*text1*_ *_marked text_* _* text2 *_" withFlags:0];
// verify
- assertThat(result, is(@"***text1*** ***marked text*** *** text2 ***"));
+ assertThat(result, is(@"_*text1*_ *_marked text_* _* text2 *_"));
}
- (void)testStringByPreprocessingString_shouldHandleMonospaceMarkers {
@@ -79,11 +79,11 @@ - (void)testStringByPreprocessingString_shouldHandleMarkdownBoldMarkers {
NSString *result1 = [processor stringByPreprocessingString:@"__text1__ __ marked __" withFlags:0];
NSString *result2 = [processor stringByPreprocessingString:@"**text1** ** marked **" withFlags:0];
// verify
- assertThat(result1, is(@"**text1** ** marked **"));
+ assertThat(result1, is(@"__text1__ __ marked __"));
assertThat(result2, is(@"**text1** ** marked **"));
}
-- (void)testStringByPreprocessingString_shouldHandleMarkdownBoldItalicsMarkers {
+- (void)testStringByPreprocessingString_shouldLeaveMarkdownBoldItalicsMarkers {
// setup
GBCommentsProcessor *processor = [self defaultProcessor];
// execute
@@ -94,11 +94,11 @@ - (void)testStringByPreprocessingString_shouldHandleMarkdownBoldItalicsMarkers {
NSString *result5 = [processor stringByPreprocessingString:@"___text1___ ___ marked ___" withFlags:0];
NSString *result6 = [processor stringByPreprocessingString:@"***text1*** *** marked ***" withFlags:0];
// verify
- assertThat(result1, is(@"***text1*** *** marked ***"));
- assertThat(result2, is(@"***text1*** *** marked ***"));
- assertThat(result3, is(@"***text1*** *** marked ***"));
- assertThat(result4, is(@"***text1*** *** marked ***"));
- assertThat(result5, is(@"***text1*** *** marked ***"));
+ assertThat(result1, is(@"__*text1*__ __* marked *__"));
+ assertThat(result2, is(@"_**text1**_ _** marked **_"));
+ assertThat(result3, is(@"*__text1__* *__ marked __*"));
+ assertThat(result4, is(@"**_text1_** **_ marked _**"));
+ assertThat(result5, is(@"___text1___ ___ marked ___"));
assertThat(result6, is(@"***text1*** *** marked ***"));
}
View
10 appledoc.xcodeproj/project.pbxproj
@@ -312,7 +312,7 @@
7367B85E11FEF76A005ED6CD /* GBObjectiveCParser-CategoryParsingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBObjectiveCParser-CategoryParsingTesting.m"; sourceTree = "<group>"; };
7367B89911FEFE4D005ED6CD /* GBObjectiveCParser-IvarsParsingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBObjectiveCParser-IvarsParsingTesting.m"; sourceTree = "<group>"; };
7367B8A211FEFFB5005ED6CD /* GBObjectiveCParser-AdoptedProtocolsParsingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBObjectiveCParser-AdoptedProtocolsParsingTesting.m"; sourceTree = "<group>"; };
- 7367B8A811FF001D005ED6CD /* GBObjectiveCParser-MethodsParsingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBObjectiveCParser-MethodsParsingTesting.m"; sourceTree = "<group>"; };
+ 7367B8A811FF001D005ED6CD /* GBObjectiveCParser-MethodsParsingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "GBObjectiveCParser-MethodsParsingTesting.m"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
7367B8D311FF07FF005ED6CD /* GBObjectiveCParser-ProtocolParsingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBObjectiveCParser-ProtocolParsingTesting.m"; sourceTree = "<group>"; };
7367BA761200135B005ED6CD /* GBClassDataTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBClassDataTesting.m; sourceTree = "<group>"; };
7367BAB812001BF7005ED6CD /* GBProtocolDataTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBProtocolDataTesting.m; sourceTree = "<group>"; };
@@ -365,12 +365,12 @@
73D54D1D11F8D53E00CCDDB0 /* DDGetoptLongParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDGetoptLongParser.m; sourceTree = "<group>"; };
73D54D2711F8D59200CCDDB0 /* GBAppledocApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBAppledocApplication.h; sourceTree = "<group>"; };
73D54D2811F8D59200CCDDB0 /* GBAppledocApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = GBAppledocApplication.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
- 73D708871267226900355DB6 /* GBApplicationSettingsProviderTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBApplicationSettingsProviderTesting.m; sourceTree = "<group>"; };
+ 73D708871267226900355DB6 /* GBApplicationSettingsProviderTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = GBApplicationSettingsProviderTesting.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
73D8E98911FCC97100966C4A /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
73D8E98B11FCC97100966C4A /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
- 73E0CF45131047E700FAFEC0 /* GBCommentsProcessor-MarkdownTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-MarkdownTesting.m"; sourceTree = "<group>"; };
+ 73E0CF45131047E700FAFEC0 /* GBCommentsProcessor-MarkdownTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "GBCommentsProcessor-MarkdownTesting.m"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
73E1B7D3130BE72100E3D710 /* GBCommentsProcessor-RegistrationsTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-RegistrationsTesting.m"; sourceTree = "<group>"; };
- 73E1B7D5130BE7C000E3D710 /* GBCommentsProcessor-PreprocessingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-PreprocessingTesting.m"; sourceTree = "<group>"; };
+ 73E1B7D5130BE7C000E3D710 /* GBCommentsProcessor-PreprocessingTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "GBCommentsProcessor-PreprocessingTesting.m"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
73EA656912B7944E00398BD1 /* Readme.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = Readme.markdown; sourceTree = "<group>"; };
73EC00BF1227EB0E0076B7B3 /* GBProcessor-KnownObjectsTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBProcessor-KnownObjectsTesting.m"; sourceTree = "<group>"; };
73EC00F71227F58F0076B7B3 /* GBProcessor-CommentsTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBProcessor-CommentsTesting.m"; sourceTree = "<group>"; };
@@ -465,7 +465,7 @@
73FC701011FCEA7200AAD0B9 /* PKToken+GBToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PKToken+GBToken.h"; sourceTree = "<group>"; };
73FC701111FCEA7200AAD0B9 /* PKToken+GBToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PKToken+GBToken.m"; sourceTree = "<group>"; };
73FC702611FCEB5300AAD0B9 /* GBTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBTokenizer.h; sourceTree = "<group>"; };
- 73FC702711FCEB5300AAD0B9 /* GBTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBTokenizer.m; sourceTree = "<group>"; };
+ 73FC702711FCEB5300AAD0B9 /* GBTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = GBTokenizer.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
73FC702C11FCEDDD00AAD0B9 /* GBTokenizerTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBTokenizerTesting.m; sourceTree = "<group>"; };
73FC729711FD925B00AAD0B9 /* GBAdoptedProtocolsProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBAdoptedProtocolsProvider.h; sourceTree = "<group>"; };
73FC729811FD925B00AAD0B9 /* GBAdoptedProtocolsProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBAdoptedProtocolsProvider.m; sourceTree = "<group>"; };

0 comments on commit a85a42b

Please sign in to comment.
Something went wrong with that request. Please try again.