GithubHelp home page GithubHelp logo

Comments (6)

darrarski avatar darrarski commented on September 27, 2024

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.

Coeur avatar Coeur commented on September 27, 2024

Hello. Thanks for reporting. I'll look into it today.

from tsmarkdownparser.

Coeur avatar Coeur commented on September 27, 2024

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.

Coeur avatar Coeur commented on September 27, 2024

I've added a visual Example project with a ViewController on Master branch. And I can't reproduce the issue visually.
image

from tsmarkdownparser.

darrarski avatar darrarski commented on September 27, 2024

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.

Coeur avatar Coeur commented on September 27, 2024

No problem.
To tell the truth, I don't use standardParser either. ;)

from tsmarkdownparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.