Penmanship Android Helpers

Useful helper methods for integrating Penmanship with your Android app.

License

License

GroupId

GroupId

com.mindsnacks
ArtifactId

ArtifactId

penmanship-helper
Last Version

Last Version

0.9
Release Date

Release Date

Type

Type

aar
Description

Description

Penmanship Android Helpers
Useful helper methods for integrating Penmanship with your Android app.
Project URL

Project URL

http://github.com/mindsnacks/penmanship
Source Code Management

Source Code Management

http://github.com/mindsnacks/penmanship

Download penmanship-helper

How to add to project

<!-- https://jarcasting.com/artifacts/com.mindsnacks/penmanship-helper/ -->
<dependency>
    <groupId>com.mindsnacks</groupId>
    <artifactId>penmanship-helper</artifactId>
    <version>0.9</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.mindsnacks/penmanship-helper/
implementation 'com.mindsnacks:penmanship-helper:0.9'
// https://jarcasting.com/artifacts/com.mindsnacks/penmanship-helper/
implementation ("com.mindsnacks:penmanship-helper:0.9")
'com.mindsnacks:penmanship-helper:aar:0.9'
<dependency org="com.mindsnacks" name="penmanship-helper" rev="0.9">
  <artifact name="penmanship-helper" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.mindsnacks', module='penmanship-helper', version='0.9')
)
libraryDependencies += "com.mindsnacks" % "penmanship-helper" % "0.9"
[com.mindsnacks/penmanship-helper "0.9"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Penmanship

A simple Gradle plug-in that makes it easy to convert Markdown documents into native Android layout XML files.

Useful for apps that require rich content and an easy way to maintain.

Screenshot 1 Screenshot 2

Build Process Integration

Add Penmanship to your buildscript depdencies and apply the plug-in:

buildscript {
  repositories {
    mavenCentral()
  }
  
  dependencies {
    classpath 'com.android.tools.build:gradle:0.7+'
    classpath 'com.mindsnacks:penmanship:CURRENT-VERSION'
  }
}

apply plugin: 'penmanship'

Then create a task to convert your Markdown files:

import com.mindsnacks.penmanship.gradle.ConvertMarkdownDirectoryToAndroidResourcesDirectoryTask
import com.android.build.gradle.tasks.ProcessAndroidResources

task generateMarkdownResources(type: ConvertMarkdownDirectoryToAndroidResourcesDirectoryTask) {
  def inputTree = file('path/to/directory/containing_only_your_markdown/and_images')
  inputs.dir inputTree
  outputs.dir file("penmanship_gen/res")
}

tasks.withType(ProcessAndroidResources) { processResourcesTask ->
  processResourcesTask.dependsOn generateMarkdownResources
}

Finally, just add your generated XML directory to your source set:

android {
  sourceSets {
    main {
      res.srcDir 'penmanship_gen/res'
    }
  }
}

App Integration

Loading Layouts

Since there is not one super common way of using the generated XML, it's up to you to inflate the layouts and integrate them into your app. Markdroid provides a very small helper library to make this easy, just add it as an app dependency:

compile 'com.mindsnacks:penmanship-helper:CURRENT-VERSION@aar'

This library provides a few methods for easily loading layout files and enabling rich text. To see an example, check out MainActivity.java in the example project.

Styling Layouts

Each Markdown element gets its own layout in the generated layout XML files. It's up to you to implement these styles. For an example implementation, refer to the example project's styles file.

Markdown Support

Markdown support is still somewhat limited. The following features work:

  1. Text formatting (bold and italics)
  2. Headings
  3. Blockquotes
  4. Unordered and ordered lists
  5. Images (only local images, can't be inline with text)
  6. Links
com.mindsnacks

Elevate

Versions

Version
0.9