All Projects → tophat → Richtextview

tophat / Richtextview

Licence: apache-2.0
iOS Text View (UIView) that Properly Displays LaTeX, HTML, Markdown, and YouTube/Vimeo Links

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Richtextview

Pylivestream
Pure Python FFmpeg-based live video / audio streaming to YouTube, Facebook, Periscope, Twitch, and more
Stars: ✭ 442 (-53.62%)
Mutual labels:  vimeo, youtube
React Player
A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
Stars: ✭ 5,931 (+522.35%)
Mutual labels:  vimeo, youtube
Redpen
RedPen is an open source proofreading tool to check if your technical documents meet the writing standard. RedPen supports various markup text formats (Markdown, Textile, AsciiDoc, Re:VIEW, reStructuredText and LaTeX).
Stars: ✭ 466 (-51.1%)
Mutual labels:  markdown, latex
Pytablewriter
pytablewriter is a Python library to write a table in various formats: CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
Stars: ✭ 422 (-55.72%)
Mutual labels:  markdown, latex
Bigpicture
Lightweight JavaScript image / video viewer. Supports Youtube, Vimeo, etc.
Stars: ✭ 722 (-24.24%)
Mutual labels:  vimeo, youtube
Lightgallery
A customizable, modular, responsive, lightbox gallery plugin.
Stars: ✭ 4,829 (+406.72%)
Mutual labels:  vimeo, youtube
Lightgallery.js
Full featured JavaScript image & video gallery. No dependencies
Stars: ✭ 5,168 (+442.29%)
Mutual labels:  vimeo, youtube
Mark Mind
MarkMind — a mind map and outliner editor for Windows, Mac, Linux, andriod and ios ,it support markdown in node.
Stars: ✭ 385 (-59.6%)
Mutual labels:  markdown, latex
Mdmath
LaTeX Math for Markdown inside of Visual Studio Code.
Stars: ✭ 675 (-29.17%)
Mutual labels:  markdown, latex
Podsync
Turn YouTube or Vimeo channels, users, or playlists into podcast feeds
Stars: ✭ 657 (-31.06%)
Mutual labels:  vimeo, youtube
Sonatamediabundle
Symfony SonataMediaBundle
Stars: ✭ 415 (-56.45%)
Mutual labels:  vimeo, youtube
Readme2tex
Renders TeXy Math for Github Readmes
Stars: ✭ 826 (-13.33%)
Mutual labels:  markdown, latex
Crowbook
Converts books written in Markdown to HTML, LaTeX/PDF and EPUB
Stars: ✭ 399 (-58.13%)
Mutual labels:  markdown, latex
Pandoc Starter
📄 My pandoc markdown templates and makefiles
Stars: ✭ 443 (-53.52%)
Mutual labels:  markdown, latex
Multimarkdown 6
Lightweight markup processor to produce HTML, LaTeX, and more.
Stars: ✭ 394 (-58.66%)
Mutual labels:  markdown, latex
Rssbox
📰 I consume the world via RSS feeds, and this is my attempt to keep it that way.
Stars: ✭ 492 (-48.37%)
Mutual labels:  vimeo, youtube
Marktext
📝A simple and elegant markdown editor, available for Linux, macOS and Windows.
Stars: ✭ 22,894 (+2302.31%)
Mutual labels:  markdown, latex
Plyr
A simple HTML5, YouTube and Vimeo player
Stars: ✭ 20,859 (+2088.77%)
Mutual labels:  vimeo, youtube
Superembed.js
Fluid width for YouTube, Vimeo, Vine, VideoPress, DailyMotion, and more embedded videos.
Stars: ✭ 615 (-35.47%)
Mutual labels:  vimeo, youtube
Raspberrycast
📺 Transform your Raspberry Pi into a streaming device. Videos can be sent from mobile devices or computers (Chrome extension).
Stars: ✭ 726 (-23.82%)
Mutual labels:  vimeo, youtube

RichTextView

Cocoapods Carthage compatible Builds
All Contributors Discord License - Apache-2 Maturity badge - level 3 Pull Reminders

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,
    isSelectable: true,
    isEditable: false,
    latexTextBaselineOffset: 0,
    interactiveTextColor: UIColor.blue,
    textViewDelegate: nil,
    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,
    latexTextBaselineOffset: 0,
    interactiveTextColor: UIColor.blue,
    completion: nil
)

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
  • isSelectable - A property that determines whether or not RichTextView is selectable
  • isEditable - A property that determines whether or not RichTextView is editable
  • latexTextBaselineOffset - The baseline offset of the attributed text attachment that represents any LaTeX text that needs to be rendered
  • interactiveTextColor - The text color of any interactive elements/custom links (see Interactive element in Formatting the input)
  • textViewDelegate - A RichTextViewDelegate - conforms to UITextViewDelegate and also has handling when interactive elements/custom links are tapped
  • frame - A CGRect that represents the frame of the RichTextView
  • 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
  • Interactive element: If you want to add text that has custom handling when you tap it, put the text in between two [interactive-element id=<id>] and [/interactive-element] tags. By doing this, when a user taps this text it will call the didTapCustomLink function of RichTextViewDelegate with the ID of the text that represents the interactive element (<id>), so be sure to hook into RichTextViewDelegate to capture this.

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!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].