Comments (6)
As a temporary workaround, I created NSString
category that removes duplicated new line characters from string:
NSString+StringByRemovingDuplicatedNewLineCharacters.h
:
#import <Foundation/Foundation.h>
@interface NSString (StringByRemovingDuplicatedNewLineCharacters)
- (NSString *)stringByRemovingDuplicatedNewLineCharacters;
@end
NSString+StringByRemovingDuplicatedNewLineCharacters.m
:
#import "NSString+StringByRemovingDuplicatedNewLineCharacters.h"
@implementation NSString (StringByRemovingDuplicatedNewLineCharacters)
- (NSString *)stringByRemovingDuplicatedNewLineCharacters
{
NSString *newLineCharacter = @"\n";
NSString *pattern = [NSString stringWithFormat:@"(%@( ){0,}){2,}", newLineCharacter];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern
options:0
error:nil];
return [regex stringByReplacingMatchesInString:self
options:0
range:NSMakeRange(0, self.length)
withTemplate:newLineCharacter];
}
@end
I am using this category to prepare markdown string before passing it to TSMarkdownParser
.
from tsmarkdownparser.
Hello. Thanks for reporting. I'll look into it today.
from tsmarkdownparser.
I've made this test:
- (void)testDefaultH1DoubleNextLine {
NSAttributedString *attributedString = [self.standardParser attributedStringFromMarkdown:@"# Header\n\nParagraph"];
UIFont *font = [attributedString attribute:NSFontAttributeName atIndex:12 effectiveRange:NULL];
UIFont *expectedFont = [UIFont systemFontOfSize:12];
XCTAssertNotNil(font);
XCTAssertEqualObjects(font, expectedFont);
XCTAssertEqual(font.pointSize, 12.f);
XCTAssertEqualObjects(attributedString.string, @"Header\n\nParagraph");
}
It is successful. So I can't reproduce your issue with unit testing. Can you provide the iOS version, Xcode version, and the exact string your are parsing?
from tsmarkdownparser.
I've added a visual Example project with a ViewController on Master branch. And I can't reproduce the issue visually.
from tsmarkdownparser.
You are right. The problem was not connected to TSMarkdownParser
itself, but it was a result of my configuration.
I am not using [TSMarkdownParser standardParser]
, because I want to set up parsing style myself. I made a mistake, and called method addHeaderParsingWithLevel:formattingBlock:
with level 0 (zero). This caused invalid formatting.
Sorry I bothered you.
from tsmarkdownparser.
No problem.
To tell the truth, I don't use standardParser either. ;)
from tsmarkdownparser.
Related Issues (20)
- Links are always blue HOT 7
- CodeEscaping is conflicting with Escaping HOT 3
- Naming question for new classes HOT 2
- Apply NSParagraphStyleAttributeName to list items via listAttributes HOT 14
- Parsing is extremely fragile? HOT 2
- tvOS broken due to unavailable font HOT 4
- Get image from a custom bundle
- Reference-style links HOT 8
- New Pod release with last commits HOT 4
- Sometimes app crashes in TSMarkdownParser init HOT 5
- Feature request: Github release with travis for Carthage HOT 1
- Link parsing conflicts with autodetection when the link text happens to be recognized as something to link as well HOT 3
- Feature request: compatibility with NSAttributedStringKey HOT 1
- Issue: Crash in MacOS 10.10 HOT 1
- Crash reported parsing markdown HOT 7
- Incorrect handling of line breaks HOT 1
- Swift Compatibility: NSString * to NSAttributedStringKey *
- The standard parser doesn't support nested lists.
- Inject the bullet point character
- SPM Release?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsmarkdownparser.