Giter Site home page Giter Site logo

zebapp / richtextview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tophat/richtextview

0.0 1.0 0.0 1.85 MB

iOS Text View (UIView) that Properly Displays LaTeX, HTML, Markdown, and YouTube/Vimeo Links

Home Page: https://richtextview.com

License: Apache License 2.0

Ruby 13.13% Swift 79.05% Objective-C 0.74% JavaScript 4.83% CSS 1.52% HTML 0.73%

richtextview's Introduction

RichTextView

Cocoapods Carthage compatible Builds Greenkeeper badge
All Contributors Slack workspace License - Apache-2 Maturity badge - level 3

iOS Text View (UIView) that Properly Displays LaTeX, HTML, Markdown, and YouTube/Vimeo Links

Installation

Using Cocoapods

Simply add the following to your Podfile:

pod 'RichTextView'

And run pod install in your repo.

Using Carthage

Simply add the following to your Cartfile:

github "tophat/RichTextView"

And run carthage update --platform iOS in your repo.

Usage

You can instantiate a RichTextView by importing the project first:

import RichTextView

To init a RichTextView:

let richTextView = RichTextView(
    input: "Test",
    latexParser: LatexParser(),
    font: UIFont.systemFont(ofSize: UIFont.systemFontSize),
    textColor: UIColor.black,
    frame: CGRect.zero,
    completion: nil
)

You can also update an existing RichTextView as follows:

richTextView.update(
    input: "Test",
    latexParser: LatexParser(),
    font: UIFont.systemFont(ofSize: UIFont.systemFontSize),
    textColor: UIColor.black,
    completion: nil
)

All of the parameters above are Optional, for both the init and update methods (except for frame). The parameters are defined as follows:

  • input - The string you want to render
  • latexParser - You can pass your own class that conforms to LatexParserProtocol if you want to handle LaTeX parsing in a custom way. Currently we use the iosMath Pod to handle LaTeX parsing by default
  • font - The font of the text to render
  • texColor - The color of the text to render
  • completion - A completion block to handle any errors that might be returned. The input will still render even if there are errors, however it might look differently than expected.

Formatting the input

In order for the RichTextView to handle the various use cases it might encounter, the input string needs to be formatted as follows:

  • LaTeX: Put any text you want to render as LaTeX in between two [math] and [/math] tags. Example: [math]x^n[/math]
  • Code: Put any text you want to render as code in between two [code] and [/code] tags. Example: [code]print('Hello World')[/code]
  • HTML/Markdown: No formatting necessary
  • YouTube Videos: Put the ID of the YouTube video in a YouTube tag as follows: youtube[dQw4w9WgXcQ]. The YouTube ID of any video can be found by looking at the URL of the video (Example: https://www.youtube.com/watch?v=dQw4w9WgXcQ) and taking the value right after the v= URL parameter. In this case the ID of the YouTube video is dQw4w9WgXcQ
  • Vimeo Videos: Put the ID of the Vimeo video in a Vimeo tag as follows: vimeo[100708006]. The Vimeo ID of any video can be found by looking at the URL of the video (Example: https://vimeo.com/100708006) and taking the value right after the first /. In this case the ID of the Vimeo video is 100708006

Screenshots

Check out the sample project in the Example root folder to see the screenshots above in action!

Architecture

Architecture

Contributing

Simply clone the repo, run pod install and you should be good to go

If you want to visually devQA your changes you can navigate to the Example project (found in the root Example folder), run pod install and then build and run the app. This will show you some common usages of the RichTextView.

The example project points to the local copy of the RichTextView pod, so any changes made locally will be reflected in the sample project.

However, you need to be on the legacy build system to see your changes reflected. There is a known issue with caching development Pods and XCode 10.

Feel free to add additional input/output examples to the example project, especially if you add any new functionality.

Also, be sure to run the unit/UI tests locally as part of the devQA process.

Credits

Thanks goes to these wonderful people (emoji key):


Ahmed Elkady

๐Ÿ’ป ๐Ÿค” โš ๏ธ

Orla Mitchell

๐Ÿ’ป ๐Ÿค” ๐Ÿ‘€

Jake Bolam

๐Ÿš‡๐Ÿ“–

Sanchit Gera

๐Ÿ“–

Monica Moore

๐ŸŽจ

Brandon Baksh

๐Ÿ“–

Siavash Bidgoly

๐Ÿš‡

Stephen Truong

๐Ÿ“–

Thanks to Carol Skelly for donating the Github organization and Kevin Zhow for donating the Pod name!

richtextview's People

Contributors

aelkady avatar jakebolam avatar orlam avatar brandonbaksh avatar syavash avatar sanchitgera avatar struong9 avatar greenkeeper[bot] avatar

Watchers

James Cloos avatar

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.