├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── markedview ├── .gitignore ├── build.gradle └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mittsu │ │ └── markedview │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── html │ │ ├── css │ │ ├── bootstrap.css │ │ ├── github-gist.css │ │ └── github.css │ │ ├── js │ │ ├── highlight.pack.js │ │ ├── jquery-2.1.4.min.js │ │ ├── marked.js │ │ └── md_preview.js │ │ └── md_preview.html │ ├── java │ └── com │ │ └── mittsu │ │ └── markedview │ │ └── MarkedView.java │ └── res │ └── values │ └── strings.xml ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mittsu │ │ └── markedviewlib │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── sample_data │ │ │ └── sample.md │ ├── java │ │ └── com │ │ │ └── mittsu │ │ │ └── markedviewlib │ │ │ ├── FileCopyManager.java │ │ │ ├── LiveReviewFragment.java │ │ │ ├── LoadFileFragment.java │ │ │ └── SampleActivity.java │ └── res │ │ ├── layout │ │ ├── activity_sample.xml │ │ ├── frag_live_preview.xml │ │ └── frag_load_mdfile.xml │ │ ├── menu │ │ └── option.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ ├── dimens.xml │ │ └── strings.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── mittsu │ └── markedviewlib │ └── ExampleUnitTest.java ├── sample_img ├── sample-lr1809170821.png └── sample-sc.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/workspace.xml 2 | /.idea/libraries 3 | .DS_Store 4 | 5 | # Created by https://www.gitignore.io/api/android 6 | 7 | ### Android ### 8 | # Built application files 9 | *.apk 10 | *.ap_ 11 | 12 | # Files for the Dalvik VM 13 | *.dex 14 | 15 | # Java class files 16 | *.class 17 | 18 | # Generated files 19 | bin/ 20 | gen/ 21 | out/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Android Studio Navigation editor temp files 37 | .navigation/ 38 | 39 | # Android Studio captures folder 40 | captures/ 41 | 42 | # Intellij 43 | *.iml 44 | 45 | # Keystore files 46 | *.jks 47 | 48 | ### Android Patch ### 49 | gen-external-apklibs 50 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | MarkedView-for-Android -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 26 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | Android API 23 Platform 58 | 59 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 mittsu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## MarkedView Example 2 | 3 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MarkedView-green.svg?style=true)](https://android-arsenal.com/details/1/3801) 4 | [![License](https://img.shields.io/badge/license-MIT-green.svg)]() 5 | [![Platform](https://img.shields.io/badge/platform-Android-green.svg) ]() 6 | [![Download](https://api.bintray.com/packages/mittsuu/maven/markedview/images/download.svg) ](https://bintray.com/mittsuu/maven/markedview/_latestVersion) 7 | 8 | 9 | ![sample_sc](https://github.com/mittsuu/MarkedView-for-Android/blob/master/sample_img/sample-sc.gif) 10 | 11 | 12 | ## Introduction 13 | 14 | 15 | The MarkedView is the markdown text viewer. 16 | 17 | 18 | ## Usage 19 | 20 | 21 | It is a simple module, which enable you to convert any files into initialized view. 22 | 23 | 24 | ```xml 25 | // xml 26 | 30 | 31 | ``` 32 | 33 | 34 | ```java 35 | // Java code 36 | 37 | import com.mittsu.markedview.MarkedView; 38 | 39 | ・・・ 40 | 41 | // call from xml 42 | MarkedView mdView = (MarkedView)findViewById(R.id.md_view); 43 | // call from code 44 | // MarkedView mdView = new MarkedView(this); 45 | 46 | // set markdown text pattern. ('contents' object is markdown text) 47 | mdView.setMDText(contents); 48 | 49 | // load Markdown file pattern. 50 | // mdView.loadFile(filePath) 51 | 52 | ``` 53 | 54 | ```java 55 | /* option */ 56 | 57 | // code block in scrolling be deactivated. 58 | mdView.setCodeScrollDisable(); 59 | 60 | ``` 61 | 62 | ## Demo 63 | 64 | * Load file 65 | 66 | Read markdown file from asset folder. 67 | 68 | * Live rendering 69 | 70 | Preview display on the right side of the input field. 71 | 72 | ![sample_lr](https://github.com/mittsuu/MarkedView-for-Android/blob/master/sample_img/sample-lr1809170821.png) 73 | 74 | 75 | ## Installation 76 | 77 | 78 | Add the dependency 79 | 80 | ```gradle 81 | dependencies { 82 | compile 'com.mittsu:markedview:1.0.7@aar' 83 | } 84 | ``` 85 | 86 | ## See Also 87 | 88 | * MarkedView-for-iOS 89 | https://github.com/mittsuu/MarkedView-for-iOS 90 | 91 | 92 | ## Credits 93 | 94 | This used the following open source components. 95 | 96 | [Marked](https://github.com/chjj/marked) : Markdown parser written in JavaScript 97 | 98 | [highlight.js](https://highlightjs.org/) : Syntax highlighting for the Web 99 | 100 | 101 | ## License 102 | 103 | 104 | MarkedView is available under the MIT license. See the [LICENSE](https://github.com/mittsuu/MarkedView-for-Android/blob/master/LICENSE) file for more info. 105 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.5.0' 9 | classpath 'com.novoda:bintray-release:0.3.4' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | } 17 | } 18 | 19 | task clean(type: Delete) { 20 | delete rootProject.buildDir 21 | } 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /markedview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /markedview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.novoda.bintray-release' 3 | 4 | android { 5 | compileSdkVersion 23 6 | buildToolsVersion "23.0.2" 7 | 8 | defaultConfig { 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 7 12 | versionName "1.0.7" 13 | } 14 | 15 | sourceSets{ 16 | main{ 17 | assets.srcDirs = ['src/main/assets'] 18 | } 19 | } 20 | } 21 | 22 | publish { 23 | userOrg = 'mittsuu' 24 | groupId = 'com.mittsu' 25 | artifactId = 'markedview' 26 | publishVersion = '1.0.7' 27 | desc = 'The MarkedView is the markdown text viewer.' 28 | website = 'https://github.com/mittsuu/MarkedView-for-Android' 29 | } 30 | -------------------------------------------------------------------------------- /markedview/src/androidTest/java/com/mittsu/markedview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /markedview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /markedview/src/main/assets/html/css/github-gist.css: -------------------------------------------------------------------------------- 1 | /** 2 | * GitHub Gist Theme 3 | * Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro 4 | */ 5 | 6 | .hljs { 7 | display: block; 8 | background: white; 9 | padding: 0.5em; 10 | color: #333333; 11 | overflow-x: auto; 12 | -webkit-text-size-adjust: none; 13 | } 14 | 15 | .hljs-comment, 16 | .bash .hljs-shebang, 17 | .java .hljs-javadoc, 18 | .javascript .hljs-javadoc, 19 | .rust .hljs-preprocessor { 20 | color: #969896; 21 | } 22 | 23 | .hljs-string, 24 | .apache .hljs-sqbracket, 25 | .coffeescript .hljs-subst, 26 | .coffeescript .hljs-regexp, 27 | .cpp .hljs-preprocessor, 28 | .c .hljs-preprocessor, 29 | .javascript .hljs-regexp, 30 | .json .hljs-attribute, 31 | .makefile .hljs-variable, 32 | .markdown .hljs-value, 33 | .markdown .hljs-link_label, 34 | .markdown .hljs-strong, 35 | .markdown .hljs-emphasis, 36 | .markdown .hljs-blockquote, 37 | .nginx .hljs-regexp, 38 | .nginx .hljs-number, 39 | .objectivec .hljs-preprocessor .hljs-title, 40 | .perl .hljs-regexp, 41 | .php .hljs-regexp, 42 | .xml .hljs-value, 43 | .less .hljs-built_in, 44 | .scss .hljs-built_in { 45 | color: #df5000; 46 | } 47 | 48 | .hljs-keyword, 49 | .css .hljs-at_rule, 50 | .css .hljs-important, 51 | .http .hljs-request, 52 | .ini .hljs-setting, 53 | .haskell .hljs-type, 54 | .java .hljs-javadoctag, 55 | .javascript .hljs-tag, 56 | .javascript .hljs-javadoctag, 57 | .nginx .hljs-title, 58 | .objectivec .hljs-preprocessor, 59 | .php .hljs-phpdoc, 60 | .sql .hljs-built_in, 61 | .less .hljs-tag, 62 | .less .hljs-at_rule, 63 | .scss .hljs-tag, 64 | .scss .hljs-at_rule, 65 | .scss .hljs-important, 66 | .stylus .hljs-at_rule, 67 | .go .hljs-typename, 68 | .swift .hljs-preprocessor { 69 | color: #a71d5d; 70 | } 71 | 72 | .apache .hljs-common, 73 | .apache .hljs-cbracket, 74 | .apache .hljs-keyword, 75 | .bash .hljs-literal, 76 | .bash .hljs-built_in, 77 | .coffeescript .hljs-literal, 78 | .coffeescript .hljs-built_in, 79 | .coffeescript .hljs-number, 80 | .cpp .hljs-number, 81 | .cpp .hljs-built_in, 82 | .c .hljs-number, 83 | .c .hljs-built_in, 84 | .cs .hljs-number, 85 | .cs .hljs-built_in, 86 | .css .hljs-attribute, 87 | .css .hljs-hexcolor, 88 | .css .hljs-number, 89 | .css .hljs-function, 90 | .haskell .hljs-number, 91 | .http .hljs-literal, 92 | .http .hljs-attribute, 93 | .java .hljs-number, 94 | .javascript .hljs-built_in, 95 | .javascript .hljs-literal, 96 | .javascript .hljs-number, 97 | .json .hljs-number, 98 | .makefile .hljs-keyword, 99 | .markdown .hljs-link_reference, 100 | .nginx .hljs-built_in, 101 | .objectivec .hljs-literal, 102 | .objectivec .hljs-number, 103 | .objectivec .hljs-built_in, 104 | .php .hljs-literal, 105 | .php .hljs-number, 106 | .python .hljs-number, 107 | .ruby .hljs-prompt, 108 | .ruby .hljs-constant, 109 | .ruby .hljs-number, 110 | .ruby .hljs-subst .hljs-keyword, 111 | .ruby .hljs-symbol, 112 | .rust .hljs-number, 113 | .sql .hljs-number, 114 | .puppet .hljs-function, 115 | .less .hljs-number, 116 | .less .hljs-hexcolor, 117 | .less .hljs-function, 118 | .less .hljs-attribute, 119 | .scss .hljs-preprocessor, 120 | .scss .hljs-number, 121 | .scss .hljs-hexcolor, 122 | .scss .hljs-function, 123 | .scss .hljs-attribute, 124 | .stylus .hljs-number, 125 | .stylus .hljs-hexcolor, 126 | .stylus .hljs-attribute, 127 | .stylus .hljs-params, 128 | .go .hljs-built_in, 129 | .go .hljs-constant, 130 | .swift .hljs-built_in, 131 | .swift .hljs-number { 132 | color: #0086b3; 133 | } 134 | 135 | .apache .hljs-tag, 136 | .cs .hljs-xmlDocTag, 137 | .css .hljs-tag, 138 | .xml .hljs-title, 139 | .stylus .hljs-tag { 140 | color: #63a35c; 141 | } 142 | 143 | .bash .hljs-variable, 144 | .cs .hljs-preprocessor, 145 | .cs .hljs-preprocessor .hljs-keyword, 146 | .css .hljs-attr_selector, 147 | .css .hljs-value, 148 | .ini .hljs-value, 149 | .ini .hljs-keyword, 150 | .javascript .hljs-tag .hljs-title, 151 | .makefile .hljs-constant, 152 | .nginx .hljs-variable, 153 | .xml .hljs-tag, 154 | .scss .hljs-variable { 155 | color: #333333; 156 | } 157 | 158 | .bash .hljs-title, 159 | .coffeescript .hljs-title, 160 | .cpp .hljs-title, 161 | .c .hljs-title, 162 | .cs .hljs-title, 163 | .css .hljs-id, 164 | .css .hljs-class, 165 | .css .hljs-pseudo, 166 | .ini .hljs-title, 167 | .haskell .hljs-title, 168 | .haskell .hljs-pragma, 169 | .java .hljs-title, 170 | .javascript .hljs-title, 171 | .makefile .hljs-title, 172 | .objectivec .hljs-title, 173 | .perl .hljs-sub, 174 | .php .hljs-title, 175 | .python .hljs-decorator, 176 | .python .hljs-title, 177 | .ruby .hljs-parent, 178 | .ruby .hljs-title, 179 | .rust .hljs-title, 180 | .xml .hljs-attribute, 181 | .puppet .hljs-title, 182 | .less .hljs-id, 183 | .less .hljs-pseudo, 184 | .less .hljs-class, 185 | .scss .hljs-id, 186 | .scss .hljs-pseudo, 187 | .scss .hljs-class, 188 | .stylus .hljs-class, 189 | .stylus .hljs-id, 190 | .stylus .hljs-pseudo, 191 | .stylus .hljs-title, 192 | .swift .hljs-title, 193 | .diff .hljs-chunk { 194 | color: #795da3; 195 | } 196 | 197 | .coffeescript .hljs-reserved, 198 | .coffeescript .hljs-attribute { 199 | color: #1d3e81; 200 | } 201 | 202 | .diff .hljs-chunk { 203 | font-weight: bold; 204 | } 205 | 206 | .diff .hljs-addition { 207 | color: #55a532; 208 | background-color: #eaffea; 209 | } 210 | 211 | .diff .hljs-deletion { 212 | color: #bd2c00; 213 | background-color: #ffecec; 214 | } 215 | 216 | .markdown .hljs-link_url { 217 | text-decoration: underline; 218 | } 219 | -------------------------------------------------------------------------------- /markedview/src/main/assets/html/css/github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | background: #f8f8f8; 13 | -webkit-text-size-adjust: none; 14 | } 15 | 16 | .hljs-comment, 17 | .diff .hljs-header { 18 | color: #998; 19 | font-style: italic; 20 | } 21 | 22 | .hljs-keyword, 23 | .css .rule .hljs-keyword, 24 | .hljs-winutils, 25 | .nginx .hljs-title, 26 | .hljs-subst, 27 | .hljs-request, 28 | .hljs-status { 29 | color: #333; 30 | font-weight: bold; 31 | } 32 | 33 | .hljs-number, 34 | .hljs-hexcolor, 35 | .ruby .hljs-constant { 36 | color: #008080; 37 | } 38 | 39 | .hljs-string, 40 | .hljs-tag .hljs-value, 41 | .hljs-doctag, 42 | .tex .hljs-formula { 43 | color: #d14; 44 | } 45 | 46 | .hljs-title, 47 | .hljs-id, 48 | .scss .hljs-preprocessor { 49 | color: #900; 50 | font-weight: bold; 51 | } 52 | 53 | .hljs-list .hljs-keyword, 54 | .hljs-subst { 55 | font-weight: normal; 56 | } 57 | 58 | .hljs-class .hljs-title, 59 | .hljs-type, 60 | .vhdl .hljs-literal, 61 | .tex .hljs-command { 62 | color: #458; 63 | font-weight: bold; 64 | } 65 | 66 | .hljs-tag, 67 | .hljs-tag .hljs-title, 68 | .hljs-rule .hljs-property, 69 | .django .hljs-tag .hljs-keyword { 70 | color: #000080; 71 | font-weight: normal; 72 | } 73 | 74 | .hljs-attribute, 75 | .hljs-variable, 76 | .lisp .hljs-body, 77 | .hljs-name { 78 | color: #008080; 79 | } 80 | 81 | .hljs-regexp { 82 | color: #009926; 83 | } 84 | 85 | .hljs-symbol, 86 | .ruby .hljs-symbol .hljs-string, 87 | .lisp .hljs-keyword, 88 | .clojure .hljs-keyword, 89 | .scheme .hljs-keyword, 90 | .tex .hljs-special, 91 | .hljs-prompt { 92 | color: #990073; 93 | } 94 | 95 | .hljs-built_in { 96 | color: #0086b3; 97 | } 98 | 99 | .hljs-preprocessor, 100 | .hljs-pragma, 101 | .hljs-pi, 102 | .hljs-doctype, 103 | .hljs-shebang, 104 | .hljs-cdata { 105 | color: #999; 106 | font-weight: bold; 107 | } 108 | 109 | .hljs-deletion { 110 | background: #fdd; 111 | } 112 | 113 | .hljs-addition { 114 | background: #dfd; 115 | } 116 | 117 | .diff .hljs-change { 118 | background: #0086b3; 119 | } 120 | 121 | .hljs-chunk { 122 | color: #aaa; 123 | } 124 | 125 | table { 126 | padding: 0; } 127 | table tr { 128 | border-top: 1px solid #cccccc; 129 | background-color: white; 130 | margin: 0; 131 | padding: 0; } 132 | table tr:nth-child(2n) { 133 | background-color: #f8f8f8; } 134 | table tr th { 135 | font-weight: bold; 136 | border: 1px solid #cccccc; 137 | text-align: left; 138 | margin: 0; 139 | padding: 6px 13px; } 140 | table tr td { 141 | border: 1px solid #cccccc; 142 | text-align: left; 143 | margin: 0; 144 | padding: 6px 13px; } 145 | table tr th :first-child, table tr td :first-child { 146 | margin-top: 0; } 147 | table tr th :last-child, table tr td :last-child { 148 | margin-bottom: 0; 149 | } -------------------------------------------------------------------------------- /markedview/src/main/assets/html/js/highlight.pack.js: -------------------------------------------------------------------------------- 1 | !function(e){"undefined"!=typeof exports?e(exports):(window.hljs=e({}),"function"==typeof define&&define.amd&&define("hljs",[],function(){return window.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&").replace(//gm,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){return/^(no-?highlight|plain|text)$/i.test(e)}function i(e){var n,t,r,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=/\blang(?:uage)?-([\w-]+)\b/i.exec(i))return w(t[1])?t[1]:"no-highlight";for(i=i.split(/\s+/),n=0,r=i.length;r>n;n++)if(w(i[n])||a(i[n]))return i[n]}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3==i.nodeType?a+=i.nodeValue.length:1==i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset"}function u(e){l+=""}function c(e){("start"==e.event?o:u)(e.node)}for(var s=0,l="",f=[];e.length||r.length;){var g=i();if(l+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g==e&&g.length&&g[0].offset==s);f.reverse().forEach(o)}else"start"==g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return l+n(a.substr(s))}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var u={},c=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");u[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?c("keyword",a.k):Object.keys(a.k).forEach(function(e){c(e,a.k[e])}),a.k=u}a.lR=t(a.l||/\b\w+\b/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var l=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=l.length?t(l.join("|"),!0):{exec:function(){return null}}}}r(e)}function l(e,t,a,i){function o(e,n){for(var t=0;t";return i+=e+'">',i+n+o}function p(){if(!L.k)return n(M);var e="",t=0;L.lR.lastIndex=0;for(var r=L.lR.exec(M);r;){e+=n(M.substr(t,r.index-t));var a=g(L,r);a?(B+=a[1],e+=h(a[0],n(r[0]))):e+=n(r[0]),t=L.lR.lastIndex,r=L.lR.exec(M)}return e+n(M.substr(t))}function d(){var e="string"==typeof L.sL;if(e&&!x[L.sL])return n(M);var t=e?l(L.sL,M,!0,y[L.sL]):f(M,L.sL.length?L.sL:void 0);return L.r>0&&(B+=t.r),e&&(y[L.sL]=t.top),h(t.language,t.value,!1,!0)}function b(){return void 0!==L.sL?d():p()}function v(e,t){var r=e.cN?h(e.cN,"",!0):"";e.rB?(k+=r,M=""):e.eB?(k+=n(t)+r,M=""):(k+=r,M=t),L=Object.create(e,{parent:{value:L}})}function m(e,t){if(M+=e,void 0===t)return k+=b(),0;var r=o(t,L);if(r)return k+=b(),v(r,t),r.rB?0:t.length;var a=u(L,t);if(a){var i=L;i.rE||i.eE||(M+=t),k+=b();do L.cN&&(k+=""),B+=L.r,L=L.parent;while(L!=a.parent);return i.eE&&(k+=n(t)),M="",a.starts&&v(a.starts,""),i.rE?0:t.length}if(c(t,L))throw new Error('Illegal lexeme "'+t+'" for mode "'+(L.cN||"")+'"');return M+=t,t.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,L=i||N,y={},k="";for(R=L;R!=N;R=R.parent)R.cN&&(k=h(R.cN,"",!0)+k);var M="",B=0;try{for(var C,j,I=0;;){if(L.t.lastIndex=I,C=L.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}for(m(t.substr(I)),R=L;R.parent;R=R.parent)R.cN&&(k+="");return{r:B,value:k,language:e,top:L}}catch(O){if(-1!=O.message.indexOf("Illegal"))return{r:0,value:n(t)};throw O}}function f(e,t){t=t||E.languages||Object.keys(x);var r={r:0,value:n(e)},a=r;return t.forEach(function(n){if(w(n)){var t=l(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}}),a.language&&(r.second_best=a),r}function g(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"
")),e}function h(e,n,t){var r=n?R[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function p(e){var n=i(e);if(!a(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):t=e;var r=t.textContent,o=n?l(n,r,!0):f(r),s=u(t);if(s.length){var p=document.createElementNS("http://www.w3.org/1999/xhtml","div");p.innerHTML=o.value,o.value=c(s,u(p),r)}o.value=g(o.value),e.innerHTML=o.value,e.className=h(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function b(){if(!b.called){b.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,p)}}function v(){addEventListener("DOMContentLoaded",b,!1),addEventListener("load",b,!1)}function m(n,t){var r=x[n]=t(e);r.aliases&&r.aliases.forEach(function(e){R[e]=n})}function N(){return Object.keys(x)}function w(e){return e=(e||"").toLowerCase(),x[e]||x[R[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},x={},R={};return e.highlight=l,e.highlightAuto=f,e.fixMarkup=g,e.highlightBlock=p,e.configure=d,e.initHighlighting=b,e.initHighlightingOnLoad=v,e.registerLanguage=m,e.listLanguages=N,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e});hljs.registerLanguage("nginx",function(e){var r={cN:"variable",v:[{b:/\$\d+/},{b:/\$\{/,e:/}/},{b:"[\\$\\@]"+e.UIR}]},b={eW:!0,l:"[a-z/_]+",k:{built_in:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll"},r:0,i:"=>",c:[e.HCM,{cN:"string",c:[e.BE,r],v:[{b:/"/,e:/"/},{b:/'/,e:/'/}]},{cN:"url",b:"([a-z]+):/",e:"\\s",eW:!0,eE:!0,c:[r]},{cN:"regexp",c:[e.BE,r],v:[{b:"\\s\\^",e:"\\s|{|;",rE:!0},{b:"~\\*?\\s+",e:"\\s|{|;",rE:!0},{b:"\\*(\\.[a-z\\-]+)+"},{b:"([a-z\\-]+\\.)+\\*"}]},{cN:"number",b:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{cN:"number",b:"\\b\\d+[kKmMgGdshdwy]*\\b",r:0},r]};return{aliases:["nginxconf"],c:[e.HCM,{b:e.UIR+"\\s",e:";|{",rB:!0,c:[{cN:"title",b:e.UIR,starts:b}],r:0}],i:"[^\\s\\}]"}});hljs.registerLanguage("cs",function(e){var r="abstract as base bool break byte case catch char checked const continue decimal dynamic default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit in int interface internal is lock long null when object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this true try typeof uint ulong unchecked unsafe ushort using virtual volatile void while async protected public private internal ascending descending from get group into join let orderby partial select set value var where yield",t=e.IR+"(<"+e.IR+">)?";return{aliases:["csharp"],k:r,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"xmlDocTag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"preprocessor",b:"#",e:"$",k:"if else elif endif define undef warning error line region endregion pragma checksum"},{cN:"string",b:'@"',e:'"',c:[{b:'""'}]},e.ASM,e.QSM,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[{cN:"title",b:"[a-zA-Z](\\.?\\w)*",r:0},e.CLCM,e.CBCM]},{bK:"new return throw await",r:0},{cN:"function",b:"("+t+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:r,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}});hljs.registerLanguage("diff",function(e){return{aliases:["patch"],c:[{cN:"chunk",r:10,v:[{b:/^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},{b:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{b:/^\-\-\- +\d+,\d+ +\-\-\-\-$/}]},{cN:"header",v:[{b:/Index: /,e:/$/},{b:/=====/,e:/=====$/},{b:/^\-\-\-/,e:/$/},{b:/^\*{3} /,e:/$/},{b:/^\+\+\+/,e:/$/},{b:/\*{5}/,e:/\*{5}$/}]},{cN:"addition",b:"^\\+",e:"$"},{cN:"deletion",b:"^\\-",e:"$"},{cN:"change",b:"^\\!",e:"$"}]}});hljs.registerLanguage("haskell",function(e){var c=[e.C("--","$"),e.C("{-","-}",{c:["self"]})],a={cN:"pragma",b:"{-#",e:"#-}"},i={cN:"preprocessor",b:"^#",e:"$"},n={cN:"type",b:"\\b[A-Z][\\w']*",r:0},t={cN:"container",b:"\\(",e:"\\)",i:'"',c:[a,i,{cN:"type",b:"\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?"},e.inherit(e.TM,{b:"[_a-z][\\w']*"})].concat(c)},l={cN:"container",b:"{",e:"}",c:t.c};return{aliases:["hs"],k:"let in if then else case of where do module import hiding qualified type data newtype deriving class instance as default infix infixl infixr foreign export ccall stdcall cplusplus jvm dotnet safe unsafe family forall mdo proc rec",c:[{cN:"module",b:"\\bmodule\\b",e:"where",k:"module where",c:[t].concat(c),i:"\\W\\.|;"},{cN:"import",b:"\\bimport\\b",e:"$",k:"import|0 qualified as hiding",c:[t].concat(c),i:"\\W\\.|;"},{cN:"class",b:"^(\\s*)?(class|instance)\\b",e:"where",k:"class family instance where",c:[n,t].concat(c)},{cN:"typedef",b:"\\b(data|(new)?type)\\b",e:"$",k:"data family type newtype deriving",c:[a,n,t,l].concat(c)},{cN:"default",bK:"default",e:"$",c:[n,t].concat(c)},{cN:"infix",bK:"infix infixl infixr",e:"$",c:[e.CNM].concat(c)},{cN:"foreign",b:"\\bforeign\\b",e:"$",k:"foreign import export ccall stdcall cplusplus jvm dotnet safe unsafe",c:[n,e.QSM].concat(c)},{cN:"shebang",b:"#!\\/usr\\/bin\\/env runhaskell",e:"$"},a,i,e.QSM,e.CNM,n,e.inherit(e.TM,{b:"^[_a-z][\\w']*"}),{b:"->|<-"}].concat(c)}});hljs.registerLanguage("groovy",function(e){return{k:{typename:"byte short char int long boolean float double void",literal:"true false null",keyword:"def as in assert trait super this abstract static volatile transient public private protected synchronized final class interface enum if else for while switch case break default continue throw throws try catch finally implements extends new import package return instanceof"},c:[e.C("/\\*\\*","\\*/",{r:0,c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,{cN:"string",b:'"""',e:'"""'},{cN:"string",b:"'''",e:"'''"},{cN:"string",b:"\\$/",e:"/\\$",r:10},e.ASM,{cN:"regexp",b:/~?\/[^\/\n]+\//,c:[e.BE]},e.QSM,{cN:"shebang",b:"^#!/usr/bin/env",e:"$",i:"\n"},e.BNM,{cN:"class",bK:"class interface trait enum",e:"{",i:":",c:[{bK:"extends implements"},e.UTM]},e.CNM,{cN:"annotation",b:"@[A-Za-z]+"},{cN:"string",b:/[^\?]{0}[A-Za-z0-9_$]+ *:/},{b:/\?/,e:/\:/},{cN:"label",b:"^\\s*[A-Za-z0-9_$]+:",r:0}],i:/#/}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/-?[a-z\.]+/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",operator:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"shebang",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,e.NM,s,a,t]}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"header",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"blockquote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{cN:"horizontal_rule",b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"link_label",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link_url",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"link_reference",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:"^\\[.+\\]:",rB:!0,c:[{cN:"link_reference",b:"\\[",e:"\\]:",eB:!0,eE:!0,starts:{cN:"link_url",e:"$"}}]}]}});hljs.registerLanguage("javascript",function(e){return{aliases:["js"],k:{keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},c:[{cN:"pi",r:10,b:/^\s*['"]use (strict|asm)['"]/},e.ASM,e.QSM,{cN:"string",b:"`",e:"`",c:[e.BE,{cN:"subst",b:"\\$\\{",e:"\\}"}]},e.CLCM,e.CBCM,{cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{b:/\s*[);\]]/,r:0,sL:"xml"}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:[e.CLCM,e.CBCM]}],i:/\[|%/},{b:/\$[(.]/},{b:"\\."+e.IR,r:0},{bK:"import",e:"[;$]",k:"import from as",c:[e.ASM,e.QSM]},{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]}],i:/#/}});hljs.registerLanguage("ini",function(e){var c={cN:"string",c:[e.BE],v:[{b:"'''",e:"'''",r:10},{b:'"""',e:'"""',r:10},{b:'"',e:'"'},{b:"'",e:"'"}]};return{aliases:["toml"],cI:!0,i:/\S/,c:[e.C(";","$"),e.HCM,{cN:"title",b:/^\s*\[+/,e:/\]+/},{cN:"setting",b:/^[a-z0-9\[\]_-]+\s*=\s*/,e:"$",c:[{cN:"value",eW:!0,k:"on off true false yes no",c:[{cN:"variable",v:[{b:/\$[\w\d"][\w\d_]*/},{b:/\$\{(.*?)}/}]},c,{cN:"number",b:/([\+\-]+)?[\d]+_[\d_]+/},e.NM],r:0}]}]}});hljs.registerLanguage("apache",function(e){var r={cN:"number",b:"[\\$%]\\d+"};return{aliases:["apacheconf"],cI:!0,c:[e.HCM,{cN:"tag",b:""},{cN:"keyword",b:/\w+/,r:0,k:{common:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername"},starts:{e:/$/,r:0,k:{literal:"on off all"},c:[{cN:"sqbracket",b:"\\s\\[",e:"\\]$"},{cN:"cbracket",b:"[\\$%]\\{",e:"\\}",c:["self",r]},r,e.QSM]}}],i:/\S/}});hljs.registerLanguage("sql",function(e){var t=e.C("--","$");return{cI:!0,i:/[<>{}*]/,c:[{cN:"operator",bK:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke",e:/;/,eW:!0,k:{keyword:"abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound buffer_cache buffer_pool build bulk by byte byteordermark bytes c cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle d data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration e each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain export export_set extended extent external external_1 external_2 externally extract f failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function g general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour http i id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists k keep keep_duplicates key keys kill l language large last last_day last_insert_id last_value lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim m main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex n name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding p package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select self sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime t table tables tablespace tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text varchar varying void"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}});hljs.registerLanguage("kotlin",function(e){var r="val var get set class trait object public open private protected final enum if else do while for when break continue throw try catch finally import package is as in return fun override default companion reified inline volatile transient native";return{k:{typename:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null",keyword:r},c:[e.C("/\\*\\*","\\*/",{r:0,c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,{cN:"type",b://,rB:!0,eE:!1,r:0},{cN:"function",bK:"fun",e:"[(]|$",rB:!0,eE:!0,k:r,i:/fun\s+(<.*>)?[^\s\(]+(\s+[^\s\(]+)\s*=/,r:5,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"type",b://,k:"reified",r:0},{cN:"params",b:/\(/,e:/\)/,k:r,r:0,i:/\([^\(,\s:]+,/,c:[{cN:"typename",b:/:\s*/,e:/\s*[=\)]/,eB:!0,rE:!0,r:0}]},e.CLCM,e.CBCM]},{cN:"class",bK:"class trait",e:/[:\{(]|$/,eE:!0,i:"extends implements",c:[e.UTM,{cN:"type",b://,eB:!0,eE:!0,r:0},{cN:"typename",b:/[,:]\s*/,e:/[<\(,]|$/,eB:!0,rE:!0}]},{cN:"variable",bK:"var val",e:/\s*[=:$]/,eE:!0},e.QSM,{cN:"shebang",b:"^#!/usr/bin/env",e:"$",i:"\n"},e.CNM]}});hljs.registerLanguage("django",function(e){var t={cN:"filter",b:/\|[A-Za-z]+:?/,k:"truncatewords removetags linebreaksbr yesno get_digit timesince random striptags filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort dictsortreversed default_if_none pluralize lower join center default truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize localtime utc timezone",c:[{cN:"argument",b:/"/,e:/"/},{cN:"argument",b:/'/,e:/'/}]};return{aliases:["jinja"],cI:!0,sL:"xml",c:[e.C(/\{%\s*comment\s*%}/,/\{%\s*endcomment\s*%}/),e.C(/\{#/,/#}/),{cN:"template_tag",b:/\{%/,e:/%}/,k:"comment endcomment load templatetag ifchanged endifchanged if endif firstof for endfor in ifnotequal endifnotequal widthratio extends include spaceless endspaceless regroup by as ifequal endifequal ssi now with cycle url filter endfilter debug block endblock else autoescape endautoescape csrf_token empty elif endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix plural get_current_language language get_available_languages get_current_language_bidi get_language_info get_language_info_list localize endlocalize localtime endlocaltime timezone endtimezone get_current_timezone verbatim",c:[t]},{cN:"variable",b:/\{\{/,e:/}}/,c:[t]}]}});hljs.registerLanguage("twig",function(e){var t={cN:"params",b:"\\(",e:"\\)"},a="attribute block constant cycle date dump include max min parent random range source template_from_string",r={cN:"function",bK:a,r:0,c:[t]},c={cN:"filter",b:/\|[A-Za-z_]+:?/,k:"abs batch capitalize convert_encoding date date_modify default escape first format join json_encode keys last length lower merge nl2br number_format raw replace reverse round slice sort split striptags title trim upper url_encode",c:[r]},n="autoescape block do embed extends filter flush for if import include macro sandbox set spaceless use verbatim";return n=n+" "+n.split(" ").map(function(e){return"end"+e}).join(" "),{aliases:["craftcms"],cI:!0,sL:"xml",c:[e.C(/\{#/,/#}/),{cN:"template_tag",b:/\{%/,e:/%}/,k:n,c:[c,r]},{cN:"variable",b:/\{\{/,e:/}}/,c:[c,r]}]}});hljs.registerLanguage("makefile",function(e){var a={cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]};return{aliases:["mk","mak"],c:[e.HCM,{b:/^\w+\s*\W*=/,rB:!0,r:0,starts:{cN:"constant",e:/\s*\W*=/,eE:!0,starts:{e:/$/,r:0,c:[a]}}},{cN:"title",b:/^[\w]+:\s*$/},{cN:"phony",b:/^\.PHONY:/,e:/$/,k:".PHONY",l:/[\.\w]+/},{b:/^\t+/,e:/$/,r:0,c:[e.QSM,a]}]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",a={cN:"function",b:c+"\\(",rB:!0,eE:!0,e:"\\("},r={cN:"rule",b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{cN:"value",eW:!0,eE:!0,c:[a,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"hexcolor",b:"#[0-9A-Fa-f]+"},{cN:"important",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"id",b:/\#[A-Za-z0-9_-]+/},{cN:"class",b:/\.[A-Za-z0-9_-]+/},{cN:"attr_selector",b:/\[/,e:/\]/,i:"$"},{cN:"pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"']+/},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{cN:"at_rule",b:"@",e:"[{;]",c:[{cN:"keyword",b:/\S+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[a,e.ASM,e.QSM,e.CSSNM]}]},{cN:"tag",b:c,r:0},{cN:"rules",b:"{",e:"}",i:/\S/,c:[e.CBCM,r]}]}});hljs.registerLanguage("elixir",function(e){var n="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?",r="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",b="and false then defined module in return redo retry end for true self when next until do begin unless nil break not case cond alias while ensure or include use alias fn quote",c={cN:"subst",b:"#\\{",e:"}",l:n,k:b},a={cN:"string",c:[e.BE,c],v:[{b:/'/,e:/'/},{b:/"/,e:/"/}]},i={cN:"function",bK:"def defp defmacro",e:/\B\b/,c:[e.inherit(e.TM,{b:n,endsParent:!0})]},s=e.inherit(i,{cN:"class",bK:"defmodule defrecord",e:/\bdo\b|$|;/}),l=[a,e.HCM,s,i,{cN:"constant",b:"(\\b[A-Z_]\\w*(.)?)+",r:0},{cN:"symbol",b:":",c:[a,{b:r}],r:0},{cN:"symbol",b:n+":",r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{b:"->"},{b:"("+e.RSR+")\\s*",c:[e.HCM,{cN:"regexp",i:"\\n",c:[e.BE,c],v:[{b:"/",e:"/[a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}],r:0}];return c.c=l,{l:n,k:b,c:l}});hljs.registerLanguage("ruby",function(e){var c="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r="and false then defined module in return redo if BEGIN retry end for true self when next until do begin unless END rescue nil else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",b={cN:"doctag",b:"@[A-Za-z]+"},a={cN:"value",b:"#<",e:">"},n=[e.C("#","$",{c:[b]}),e.C("^\\=begin","^\\=end",{c:[b],r:10}),e.C("^__END__","\\n$")],s={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,s],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/}]},i={cN:"params",b:"\\(",e:"\\)",k:r},d=[t,a,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+e.IR+"::)?"+e.IR}]}].concat(n)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:c}),i].concat(n)},{cN:"constant",b:"(::)?(\\b[A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":",c:[t,{b:c}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{b:"("+e.RSR+")\\s*",c:[a,{cN:"regexp",c:[e.BE,s],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(n),r:0}].concat(n);s.c=d,i.c=d;var o="[>?]>",l="[\\w#]+\\(\\w+\\):\\d+:\\d+>",u="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",N=[{b:/^\s*=>/,cN:"status",starts:{e:"$",c:d}},{cN:"prompt",b:"^("+o+"|"+l+"|"+u+")",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:n.concat(N).concat(d)}});hljs.registerLanguage("xml",function(t){var s="[A-Za-z0-9\\._:-]+",c={b:/<\?(php)?(?!\w)/,e:/\?>/,sL:"php"},e={eW:!0,i:/]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xsl","plist"],cI:!0,c:[{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},t.C("",{r:10}),{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"|$)",e:">",k:{title:"style"},c:[e],starts:{e:"",rE:!0,sL:"css"}},{cN:"tag",b:"|$)",e:">",k:{title:"script"},c:[e],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars"]}},c,{cN:"pi",b:/<\?\w+/,e:/\?>/,r:10},{cN:"tag",b:"",c:[{cN:"title",b:/[^ \/><\n\t]+/,r:0},e]}]}});hljs.registerLanguage("objectivec",function(e){var t={cN:"built_in",b:"(AV|CA|CF|CG|CI|MK|MP|NS|UI)\\w+"},i={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},o=/[a-zA-Z@][a-zA-Z0-9_]*/,n="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:i,l:o,i:""}]}]},{cN:"class",b:"("+n.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:n,l:o,c:[e.UTM]},{cN:"variable",b:"\\."+e.UIR,r:0}]}});hljs.registerLanguage("python",function(e){var r={cN:"prompt",b:/^(>>>|\.\.\.) /},b={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[r],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[r],r:10},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},e.ASM,e.QSM]},a={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},l={cN:"params",b:/\(/,e:/\)/,c:["self",r,a,b]};return{aliases:["py","gyp"],k:{keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10 None True False",built_in:"Ellipsis NotImplemented"},i:/(<\/|->|\?)/,c:[r,a,b,e.HCM,{v:[{cN:"function",bK:"def",r:10},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,l]},{cN:"decorator",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}});hljs.registerLanguage("scala",function(e){var t={cN:"annotation",b:"@[A-Za-z]+"},r={cN:"string",b:'u?r?"""',e:'"""',r:10},a={cN:"symbol",b:"'\\w[\\w\\d_]*(?!')"},c={cN:"type",b:"\\b[A-Z][A-Za-z0-9_]*",r:0},i={cN:"title",b:/[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/,r:0},n={cN:"class",bK:"class object trait type",e:/[:={\[(\n;]/,c:[{cN:"keyword",bK:"extends with",r:10},i]},l={cN:"function",bK:"def",e:/[:={\[(\n;]/,c:[i]};return{k:{literal:"true false null",keyword:"type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit"},c:[e.CLCM,e.CBCM,r,e.QSM,a,c,l,n,e.CNM,t]}});hljs.registerLanguage("swift",function(e){var i={keyword:"__COLUMN__ __FILE__ __FUNCTION__ __LINE__ as as! as? associativity break case catch class continue convenience default defer deinit didSet do dynamic dynamicType else enum extension fallthrough false final for func get guard if import in indirect infix init inout internal is lazy left let mutating nil none nonmutating operator optional override postfix precedence prefix private protocol Protocol public repeat required rethrows return right self Self set static struct subscript super switch throw throws true try try! try? Type typealias unowned var weak where while willSet",literal:"true false nil",built_in:"abs advance alignof alignofValue anyGenerator assert assertionFailure bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC bridgeToObjectiveCUnconditional c contains count countElements countLeadingZeros debugPrint debugPrintln distance dropFirst dropLast dump encodeBitsAsWords enumerate equal fatalError filter find getBridgedObjectiveCType getVaList indices insertionSort isBridgedToObjectiveC isBridgedVerbatimToObjectiveC isUniquelyReferenced isUniquelyReferencedNonObjC join lazy lexicographicalCompare map max maxElement min minElement numericCast overlaps partition posix precondition preconditionFailure print println quickSort readLine reduce reflect reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split startsWith stride strideof strideofValue swap toString transcode underestimateCount unsafeAddressOf unsafeBitCast unsafeDowncast unsafeUnwrap unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer withUnsafePointerToObject withUnsafeMutablePointer withUnsafeMutablePointers withUnsafePointer withUnsafePointers withVaList zip"},t={cN:"type",b:"\\b[A-Z][\\w']*",r:0},n=e.C("/\\*","\\*/",{c:["self"]}),r={cN:"subst",b:/\\\(/,e:"\\)",k:i,c:[]},a={cN:"number",b:"\\b([\\d_]+(\\.[\\deE_]+)?|0x[a-fA-F0-9_]+(\\.[a-fA-F0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b",r:0},o=e.inherit(e.QSM,{c:[r,e.BE]});return r.c=[a],{k:i,c:[o,e.CLCM,n,t,a,{cN:"func",bK:"func",e:"{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/,i:/\(/}),{cN:"generics",b://,i:/>/},{cN:"params",b:/\(/,e:/\)/,endsParent:!0,k:i,c:["self",a,o,e.CBCM,{b:":"}],i:/["']/}],i:/\[|%/},{cN:"class",bK:"struct protocol class extension enum",k:i,e:"\\{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/})]},{cN:"preprocessor",b:"(@warn_unused_result|@exported|@lazy|@noescape|@NSCopying|@NSManaged|@objc|@convention|@required|@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|@infix|@prefix|@postfix|@autoclosure|@testable|@available|@nonobjc|@NSApplicationMain|@UIApplicationMain)"},{bK:"import",e:/$/,c:[e.CLCM,n]}]}});hljs.registerLanguage("lua",function(e){var t="\\[=*\\[",a="\\]=*\\]",r={b:t,e:a,c:["self"]},n=[e.C("--(?!"+t+")","$"),e.C("--"+t,a,{c:[r],r:10})];return{l:e.UIR,k:{keyword:"and break do else elseif end false for if in local nil not or repeat return then true until while",built_in:"_G _VERSION assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall coroutine debug io math os package string table"},c:n.concat([{cN:"function",bK:"function",e:"\\)",c:[e.inherit(e.TM,{b:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{cN:"params",b:"\\(",eW:!0,c:n}].concat(n)},e.CNM,e.ASM,e.QSM,{cN:"string",b:t,e:a,c:[r],r:5}])}});hljs.registerLanguage("coffeescript",function(e){var c={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},n="[A-Za-z$_][0-9A-Za-z$_]*",r={cN:"subst",b:/#\{/,e:/}/,k:c},t=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,r]},{b:/"/,e:/"/,c:[e.BE,r]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[r,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{cN:"property",b:"@"+n},{b:"`",e:"`",eB:!0,eE:!0,sL:"javascript"}];r.c=t;var s=e.inherit(e.TM,{b:n}),i="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:c,c:["self"].concat(t)}]};return{aliases:["coffee","cson","iced"],k:c,i:/\/\*/,c:t.concat([e.C("###","###"),e.HCM,{cN:"function",b:"^\\s*"+n+"\\s*=\\s*"+i,e:"[-=]>",rB:!0,c:[s,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:i,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[s]},s]},{cN:"attribute",b:n+":",e:":",rB:!0,rE:!0,r:0}])}});hljs.registerLanguage("gradle",function(e){return{cI:!0,k:{keyword:"task project allprojects subprojects artifacts buildscript configurations dependencies repositories sourceSets description delete from into include exclude source classpath destinationDir includes options sourceCompatibility targetCompatibility group flatDir doLast doFirst flatten todir fromdir ant def abstract break case catch continue default do else extends final finally for if implements instanceof native new private protected public return static switch synchronized throw throws transient try volatile while strictfp package import false null super this true antlrtask checkstyle codenarc copy boolean byte char class double float int interface long short void compile runTime file fileTree abs any append asList asWritable call collect compareTo count div dump each eachByte eachFile eachLine every find findAll flatten getAt getErr getIn getOut getText grep immutable inject inspect intersect invokeMethods isCase join leftShift minus multiply newInputStream newOutputStream newPrintWriter newReader newWriter next plus pop power previous print println push putAt read readBytes readLines reverse reverseEach round size sort splitEachLine step subMap times toInteger toList tokenize upto waitForOrKill withPrintWriter withReader withStream withWriter withWriterAppend write writeLine"},c:[e.CLCM,e.CBCM,e.ASM,e.QSM,e.NM,e.RM]}});hljs.registerLanguage("perl",function(e){var t="getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qqfileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmgetsub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedirioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when",r={cN:"subst",b:"[$@]\\{",e:"\\}",k:t},s={b:"->{",e:"}"},n={cN:"variable",v:[{b:/\$\d/},{b:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{b:/[\$%@][^\s\w{]/,r:0}]},o=[e.BE,r,n],i=[n,e.HCM,e.C("^\\=\\w","\\=cut",{eW:!0}),s,{cN:"string",c:o,v:[{b:"q[qwxr]?\\s*\\(",e:"\\)",r:5},{b:"q[qwxr]?\\s*\\[",e:"\\]",r:5},{b:"q[qwxr]?\\s*\\{",e:"\\}",r:5},{b:"q[qwxr]?\\s*\\|",e:"\\|",r:5},{b:"q[qwxr]?\\s*\\<",e:"\\>",r:5},{b:"qw\\s+q",e:"q",r:5},{b:"'",e:"'",c:[e.BE]},{b:'"',e:'"'},{b:"`",e:"`",c:[e.BE]},{b:"{\\w+}",c:[],r:0},{b:"-?\\w+\\s*\\=\\>",c:[],r:0}]},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\/\\/|"+e.RSR+"|\\b(split|return|print|reverse|grep)\\b)\\s*",k:"split return print reverse grep",r:0,c:[e.HCM,{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[e.BE],r:0}]},{cN:"sub",bK:"sub",e:"(\\s*\\(.*?\\))?[;{]",r:5},{cN:"operator",b:"-\\w\\b",r:0},{b:"^__DATA__$",e:"^__END__$",sL:"mojolicious",c:[{b:"^@@.*",e:"$",cN:"comment"}]}];return r.c=i,s.c=i,{aliases:["pl"],k:t,c:i}});hljs.registerLanguage("erlang",function(e){var r="[a-z'][a-zA-Z0-9_']*",c="("+r+":"+r+"|"+r+")",a={keyword:"after and andalso|10 band begin bnot bor bsl bzr bxor case catch cond div end fun if let not of orelse|10 query receive rem try when xor",literal:"false true"},n=e.C("%","$"),i={cN:"number",b:"\\b(\\d+#[a-fA-F0-9]+|\\d+(\\.\\d+)?([eE][-+]?\\d+)?)",r:0},b={b:"fun\\s+"+r+"/\\d+"},d={b:c+"\\(",e:"\\)",rB:!0,r:0,c:[{cN:"function_name",b:c,r:0},{b:"\\(",e:"\\)",eW:!0,rE:!0,r:0}]},o={cN:"tuple",b:"{",e:"}",r:0},t={cN:"variable",b:"\\b_([A-Z][A-Za-z0-9_]*)?",r:0},l={cN:"variable",b:"[A-Z][a-zA-Z0-9_]*",r:0},f={b:"#"+e.UIR,r:0,rB:!0,c:[{cN:"record_name",b:"#"+e.UIR,r:0},{b:"{",e:"}",r:0}]},s={bK:"fun receive if try case",e:"end",k:a};s.c=[n,b,e.inherit(e.ASM,{cN:""}),s,d,e.QSM,i,o,t,l,f];var u=[n,b,s,d,e.QSM,i,o,t,l,f];d.c[1].c=u,o.c=u,f.c[1].c=u;var v={cN:"params",b:"\\(",e:"\\)",c:u};return{aliases:["erl"],k:a,i:"(",rB:!0,i:"\\(|#|//|/\\*|\\\\|:|;",c:[v,e.inherit(e.TM,{b:r})],starts:{e:";|\\.",k:a,c:u}},n,{cN:"pp",b:"^-",e:"\\.",r:0,eE:!0,rB:!0,l:"-"+e.IR,k:"-module -record -undef -export -ifdef -ifndef -author -copyright -doc -vsn -import -include -include_lib -compile -define -else -endif -file -behaviour -behavior -spec",c:[v]},i,e.QSM,f,t,l,o,{b:/\.$/}]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[t.inherit(t.QSM,{b:'((u8?|U)|L)?"'}),{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)"},{b:t.CNR}]},i={cN:"preprocessor",b:"#",e:"$",k:"if else elif endif define undef warning error line pragma ifdef ifndef",c:[{b:/\\\n/,r:0},{bK:"include",e:"$",c:[r,{cN:"string",b:"<",e:">",i:"\\n"}]},r,s,t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using class asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf",literal:"true false nullptr NULL"};return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{bK:"new throw return else",r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s]},t.CLCM,t.CBCM,i]}]}});hljs.registerLanguage("http",function(t){return{aliases:["https"],i:"\\S",c:[{cN:"status",b:"^HTTP/[0-9\\.]+",e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{cN:"request",b:"^[A-Z]+ (.*?) HTTP/[0-9\\.]+$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{cN:"string",e:"$"}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}});hljs.registerLanguage("json",function(e){var t={literal:"true false null"},i=[e.QSM,e.CNM],l={cN:"value",e:",",eW:!0,eE:!0,c:i,k:t},c={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:!0,eE:!0,c:[e.BE],i:"\\n",starts:l}],i:"\\S"},n={b:"\\[",e:"\\]",c:[e.inherit(l,{cN:null})],i:"\\S"};return i.splice(i.length,0,c,n),{c:i,k:t,i:"\\S"}});hljs.registerLanguage("scss",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",i={cN:"variable",b:"(\\$"+t+")\\b"},r={cN:"function",b:t+"\\(",rB:!0,eE:!0,e:"\\("},o={cN:"hexcolor",b:"#[0-9A-Fa-f]+"};({cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{cN:"value",eW:!0,eE:!0,c:[r,o,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"important",b:"!important"}]}});return{cI:!0,i:"[=/|']",c:[e.CLCM,e.CBCM,r,{cN:"id",b:"\\#[A-Za-z0-9_-]+",r:0},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"tag",b:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",r:0},{cN:"pseudo",b:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{cN:"pseudo",b:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},i,{cN:"attribute",b:"\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",i:"[^\\s]"},{cN:"value",b:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{cN:"value",b:":",e:";",c:[r,i,o,e.CSSNM,e.QSM,e.ASM,{cN:"important",b:"!important"}]},{cN:"at_rule",b:"@",e:"[{;]",k:"mixin include extend for if else each while charset import debug media page content font-face namespace warn",c:[r,i,e.QSM,e.ASM,o,e.CSSNM,{cN:"preprocessor",b:"\\s[A-Za-z0-9_.-]+",r:0}]}]}});hljs.registerLanguage("java",function(e){var a=e.UIR+"(<"+e.UIR+">)?",t="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private",c="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",r={cN:"number",b:c,r:0};return{aliases:["jsp"],k:t,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+a+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:t,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:t,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},r,{cN:"annotation",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("php",function(e){var c={cN:"variable",b:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},a={cN:"preprocessor",b:/<\?(php)?|\?>/},i={cN:"string",c:[e.BE,a],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},t={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.CLCM,e.HCM,e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"},a]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},a,c,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",c,e.CBCM,i,t]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},i,t]}});hljs.registerLanguage("go",function(e){var t={keyword:"break default func interface select case map struct chan else goto package switch const fallthrough if range type continue for import return var go defer",constant:"true false iota nil",typename:"bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune",built_in:"append cap close complex copy imag len make new panic print println real recover delete"};return{aliases:["golang"],k:t,i:"[^\n]+(\n(?!def)[^\n]+)*\n*)+/, 22 | list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, 23 | html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/, 24 | def: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, 25 | table: noop, 26 | paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, 27 | text: /^[^\n]+/ 28 | }; 29 | 30 | block.bullet = /(?:[*+-]|\d+\.)/; 31 | block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; 32 | block.item = replace(block.item, 'gm') 33 | (/bull/g, block.bullet) 34 | (); 35 | 36 | block.list = replace(block.list) 37 | (/bull/g, block.bullet) 38 | ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))') 39 | ('def', '\\n+(?=' + block.def.source + ')') 40 | (); 41 | 42 | block.blockquote = replace(block.blockquote) 43 | ('def', block.def) 44 | (); 45 | 46 | block._tag = '(?!(?:' 47 | + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' 48 | + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' 49 | + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b'; 50 | 51 | block.html = replace(block.html) 52 | ('comment', //) 53 | ('closed', /<(tag)[\s\S]+?<\/\1>/) 54 | ('closing', /])*?>/) 55 | (/tag/g, block._tag) 56 | (); 57 | 58 | block.paragraph = replace(block.paragraph) 59 | ('hr', block.hr) 60 | ('heading', block.heading) 61 | ('lheading', block.lheading) 62 | ('blockquote', block.blockquote) 63 | ('tag', '<' + block._tag) 64 | ('def', block.def) 65 | (); 66 | 67 | /** 68 | * Normal Block Grammar 69 | */ 70 | 71 | block.normal = merge({}, block); 72 | 73 | /** 74 | * GFM Block Grammar 75 | */ 76 | 77 | block.gfm = merge({}, block.normal, { 78 | fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/, 79 | paragraph: /^/, 80 | heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/ 81 | }); 82 | 83 | block.gfm.paragraph = replace(block.paragraph) 84 | ('(?!', '(?!' 85 | + block.gfm.fences.source.replace('\\1', '\\2') + '|' 86 | + block.list.source.replace('\\1', '\\3') + '|') 87 | (); 88 | 89 | /** 90 | * GFM + Tables Block Grammar 91 | */ 92 | 93 | block.tables = merge({}, block.gfm, { 94 | nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, 95 | table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/ 96 | }); 97 | 98 | /** 99 | * Block Lexer 100 | */ 101 | 102 | function Lexer(options) { 103 | this.tokens = []; 104 | this.tokens.links = {}; 105 | this.options = options || marked.defaults; 106 | this.rules = block.normal; 107 | 108 | if (this.options.gfm) { 109 | if (this.options.tables) { 110 | this.rules = block.tables; 111 | } else { 112 | this.rules = block.gfm; 113 | } 114 | } 115 | } 116 | 117 | /** 118 | * Expose Block Rules 119 | */ 120 | 121 | Lexer.rules = block; 122 | 123 | /** 124 | * Static Lex Method 125 | */ 126 | 127 | Lexer.lex = function(src, options) { 128 | var lexer = new Lexer(options); 129 | return lexer.lex(src); 130 | }; 131 | 132 | /** 133 | * Preprocessing 134 | */ 135 | 136 | Lexer.prototype.lex = function(src) { 137 | src = src 138 | .replace(/\r\n|\r/g, '\n') 139 | .replace(/\t/g, ' ') 140 | .replace(/\u00a0/g, ' ') 141 | .replace(/\u2424/g, '\n'); 142 | 143 | return this.token(src, true); 144 | }; 145 | 146 | /** 147 | * Lexing 148 | */ 149 | 150 | Lexer.prototype.token = function(src, top, bq) { 151 | var src = src.replace(/^ +$/gm, '') 152 | , next 153 | , loose 154 | , cap 155 | , bull 156 | , b 157 | , item 158 | , space 159 | , i 160 | , l; 161 | 162 | while (src) { 163 | // newline 164 | if (cap = this.rules.newline.exec(src)) { 165 | src = src.substring(cap[0].length); 166 | if (cap[0].length > 1) { 167 | this.tokens.push({ 168 | type: 'space' 169 | }); 170 | } 171 | } 172 | 173 | // code 174 | if (cap = this.rules.code.exec(src)) { 175 | src = src.substring(cap[0].length); 176 | cap = cap[0].replace(/^ {4}/gm, ''); 177 | this.tokens.push({ 178 | type: 'code', 179 | text: !this.options.pedantic 180 | ? cap.replace(/\n+$/, '') 181 | : cap 182 | }); 183 | continue; 184 | } 185 | 186 | // fences (gfm) 187 | if (cap = this.rules.fences.exec(src)) { 188 | src = src.substring(cap[0].length); 189 | this.tokens.push({ 190 | type: 'code', 191 | lang: cap[2], 192 | text: cap[3] || '' 193 | }); 194 | continue; 195 | } 196 | 197 | // heading 198 | if (cap = this.rules.heading.exec(src)) { 199 | src = src.substring(cap[0].length); 200 | this.tokens.push({ 201 | type: 'heading', 202 | depth: cap[1].length, 203 | text: cap[2] 204 | }); 205 | continue; 206 | } 207 | 208 | // table no leading pipe (gfm) 209 | if (top && (cap = this.rules.nptable.exec(src))) { 210 | src = src.substring(cap[0].length); 211 | 212 | item = { 213 | type: 'table', 214 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), 215 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), 216 | cells: cap[3].replace(/\n$/, '').split('\n') 217 | }; 218 | 219 | for (i = 0; i < item.align.length; i++) { 220 | if (/^ *-+: *$/.test(item.align[i])) { 221 | item.align[i] = 'right'; 222 | } else if (/^ *:-+: *$/.test(item.align[i])) { 223 | item.align[i] = 'center'; 224 | } else if (/^ *:-+ *$/.test(item.align[i])) { 225 | item.align[i] = 'left'; 226 | } else { 227 | item.align[i] = null; 228 | } 229 | } 230 | 231 | for (i = 0; i < item.cells.length; i++) { 232 | item.cells[i] = item.cells[i].split(/ *\| */); 233 | } 234 | 235 | this.tokens.push(item); 236 | 237 | continue; 238 | } 239 | 240 | // lheading 241 | if (cap = this.rules.lheading.exec(src)) { 242 | src = src.substring(cap[0].length); 243 | this.tokens.push({ 244 | type: 'heading', 245 | depth: cap[2] === '=' ? 1 : 2, 246 | text: cap[1] 247 | }); 248 | continue; 249 | } 250 | 251 | // hr 252 | if (cap = this.rules.hr.exec(src)) { 253 | src = src.substring(cap[0].length); 254 | this.tokens.push({ 255 | type: 'hr' 256 | }); 257 | continue; 258 | } 259 | 260 | // blockquote 261 | if (cap = this.rules.blockquote.exec(src)) { 262 | src = src.substring(cap[0].length); 263 | 264 | this.tokens.push({ 265 | type: 'blockquote_start' 266 | }); 267 | 268 | cap = cap[0].replace(/^ *> ?/gm, ''); 269 | 270 | // Pass `top` to keep the current 271 | // "toplevel" state. This is exactly 272 | // how markdown.pl works. 273 | this.token(cap, top, true); 274 | 275 | this.tokens.push({ 276 | type: 'blockquote_end' 277 | }); 278 | 279 | continue; 280 | } 281 | 282 | // list 283 | if (cap = this.rules.list.exec(src)) { 284 | src = src.substring(cap[0].length); 285 | bull = cap[2]; 286 | 287 | this.tokens.push({ 288 | type: 'list_start', 289 | ordered: bull.length > 1 290 | }); 291 | 292 | // Get each top-level item. 293 | cap = cap[0].match(this.rules.item); 294 | 295 | next = false; 296 | l = cap.length; 297 | i = 0; 298 | 299 | for (; i < l; i++) { 300 | item = cap[i]; 301 | 302 | // Remove the list item's bullet 303 | // so it is seen as the next token. 304 | space = item.length; 305 | item = item.replace(/^ *([*+-]|\d+\.) +/, ''); 306 | 307 | // Outdent whatever the 308 | // list item contains. Hacky. 309 | if (~item.indexOf('\n ')) { 310 | space -= item.length; 311 | item = !this.options.pedantic 312 | ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') 313 | : item.replace(/^ {1,4}/gm, ''); 314 | } 315 | 316 | // Determine whether the next list item belongs here. 317 | // Backpedal if it does not belong in this list. 318 | if (this.options.smartLists && i !== l - 1) { 319 | b = block.bullet.exec(cap[i + 1])[0]; 320 | if (bull !== b && !(bull.length > 1 && b.length > 1)) { 321 | src = cap.slice(i + 1).join('\n') + src; 322 | i = l - 1; 323 | } 324 | } 325 | 326 | // Determine whether item is loose or not. 327 | // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/ 328 | // for discount behavior. 329 | loose = next || /\n\n(?!\s*$)/.test(item); 330 | if (i !== l - 1) { 331 | next = item.charAt(item.length - 1) === '\n'; 332 | if (!loose) loose = next; 333 | } 334 | 335 | this.tokens.push({ 336 | type: loose 337 | ? 'loose_item_start' 338 | : 'list_item_start' 339 | }); 340 | 341 | // Recurse. 342 | this.token(item, false, bq); 343 | 344 | this.tokens.push({ 345 | type: 'list_item_end' 346 | }); 347 | } 348 | 349 | this.tokens.push({ 350 | type: 'list_end' 351 | }); 352 | 353 | continue; 354 | } 355 | 356 | // html 357 | if (cap = this.rules.html.exec(src)) { 358 | src = src.substring(cap[0].length); 359 | this.tokens.push({ 360 | type: this.options.sanitize 361 | ? 'paragraph' 362 | : 'html', 363 | pre: !this.options.sanitizer 364 | && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'), 365 | text: cap[0] 366 | }); 367 | continue; 368 | } 369 | 370 | // def 371 | if ((!bq && top) && (cap = this.rules.def.exec(src))) { 372 | src = src.substring(cap[0].length); 373 | this.tokens.links[cap[1].toLowerCase()] = { 374 | href: cap[2], 375 | title: cap[3] 376 | }; 377 | continue; 378 | } 379 | 380 | // table (gfm) 381 | if (top && (cap = this.rules.table.exec(src))) { 382 | src = src.substring(cap[0].length); 383 | 384 | item = { 385 | type: 'table', 386 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), 387 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), 388 | cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') 389 | }; 390 | 391 | for (i = 0; i < item.align.length; i++) { 392 | if (/^ *-+: *$/.test(item.align[i])) { 393 | item.align[i] = 'right'; 394 | } else if (/^ *:-+: *$/.test(item.align[i])) { 395 | item.align[i] = 'center'; 396 | } else if (/^ *:-+ *$/.test(item.align[i])) { 397 | item.align[i] = 'left'; 398 | } else { 399 | item.align[i] = null; 400 | } 401 | } 402 | 403 | for (i = 0; i < item.cells.length; i++) { 404 | item.cells[i] = item.cells[i] 405 | .replace(/^ *\| *| *\| *$/g, '') 406 | .split(/ *\| */); 407 | } 408 | 409 | this.tokens.push(item); 410 | 411 | continue; 412 | } 413 | 414 | // top-level paragraph 415 | if (top && (cap = this.rules.paragraph.exec(src))) { 416 | src = src.substring(cap[0].length); 417 | this.tokens.push({ 418 | type: 'paragraph', 419 | text: cap[1].charAt(cap[1].length - 1) === '\n' 420 | ? cap[1].slice(0, -1) 421 | : cap[1] 422 | }); 423 | continue; 424 | } 425 | 426 | // text 427 | if (cap = this.rules.text.exec(src)) { 428 | // Top-level should never reach here. 429 | src = src.substring(cap[0].length); 430 | this.tokens.push({ 431 | type: 'text', 432 | text: cap[0] 433 | }); 434 | continue; 435 | } 436 | 437 | if (src) { 438 | throw new 439 | Error('Infinite loop on byte: ' + src.charCodeAt(0)); 440 | } 441 | } 442 | 443 | return this.tokens; 444 | }; 445 | 446 | /** 447 | * Inline-Level Grammar 448 | */ 449 | 450 | var inline = { 451 | escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, 452 | autolink: /^<([^ >]+(@|:\/)[^ >]+)>/, 453 | url: noop, 454 | tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/, 455 | link: /^!?\[(inside)\]\(href\)/, 456 | reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, 457 | nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/, 458 | strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, 459 | em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, 460 | code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/, 461 | br: /^ {2,}\n(?!\s*$)/, 462 | del: noop, 463 | text: /^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/; 468 | 469 | inline.link = replace(inline.link) 470 | ('inside', inline._inside) 471 | ('href', inline._href) 472 | (); 473 | 474 | inline.reflink = replace(inline.reflink) 475 | ('inside', inline._inside) 476 | (); 477 | 478 | /** 479 | * Normal Inline Grammar 480 | */ 481 | 482 | inline.normal = merge({}, inline); 483 | 484 | /** 485 | * Pedantic Inline Grammar 486 | */ 487 | 488 | inline.pedantic = merge({}, inline.normal, { 489 | strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, 490 | em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/ 491 | }); 492 | 493 | /** 494 | * GFM Inline Grammar 495 | */ 496 | 497 | inline.gfm = merge({}, inline.normal, { 498 | escape: replace(inline.escape)('])', '~|])')(), 499 | url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/, 500 | del: /^~~(?=\S)([\s\S]*?\S)~~/, 501 | text: replace(inline.text) 502 | (']|', '~]|') 503 | ('|', '|https?://|') 504 | () 505 | }); 506 | 507 | /** 508 | * GFM + Line Breaks Inline Grammar 509 | */ 510 | 511 | inline.breaks = merge({}, inline.gfm, { 512 | br: replace(inline.br)('{2,}', '*')(), 513 | text: replace(inline.gfm.text)('{2,}', '*')() 514 | }); 515 | 516 | /** 517 | * Inline Lexer & Compiler 518 | */ 519 | 520 | function InlineLexer(links, options) { 521 | this.options = options || marked.defaults; 522 | this.links = links; 523 | this.rules = inline.normal; 524 | this.renderer = this.options.renderer || new Renderer; 525 | this.renderer.options = this.options; 526 | 527 | if (!this.links) { 528 | throw new 529 | Error('Tokens array requires a `links` property.'); 530 | } 531 | 532 | if (this.options.gfm) { 533 | if (this.options.breaks) { 534 | this.rules = inline.breaks; 535 | } else { 536 | this.rules = inline.gfm; 537 | } 538 | } else if (this.options.pedantic) { 539 | this.rules = inline.pedantic; 540 | } 541 | } 542 | 543 | /** 544 | * Expose Inline Rules 545 | */ 546 | 547 | InlineLexer.rules = inline; 548 | 549 | /** 550 | * Static Lexing/Compiling Method 551 | */ 552 | 553 | InlineLexer.output = function(src, links, options) { 554 | var inline = new InlineLexer(links, options); 555 | return inline.output(src); 556 | }; 557 | 558 | /** 559 | * Lexing/Compiling 560 | */ 561 | 562 | InlineLexer.prototype.output = function(src) { 563 | var out = '' 564 | , link 565 | , text 566 | , href 567 | , cap; 568 | 569 | while (src) { 570 | // escape 571 | if (cap = this.rules.escape.exec(src)) { 572 | src = src.substring(cap[0].length); 573 | out += cap[1]; 574 | continue; 575 | } 576 | 577 | // autolink 578 | if (cap = this.rules.autolink.exec(src)) { 579 | src = src.substring(cap[0].length); 580 | if (cap[2] === '@') { 581 | text = cap[1].charAt(6) === ':' 582 | ? this.mangle(cap[1].substring(7)) 583 | : this.mangle(cap[1]); 584 | href = this.mangle('mailto:') + text; 585 | } else { 586 | text = escape(cap[1]); 587 | href = text; 588 | } 589 | out += this.renderer.link(href, null, text); 590 | continue; 591 | } 592 | 593 | // url (gfm) 594 | if (!this.inLink && (cap = this.rules.url.exec(src))) { 595 | src = src.substring(cap[0].length); 596 | text = escape(cap[1]); 597 | href = text; 598 | out += this.renderer.link(href, null, text); 599 | continue; 600 | } 601 | 602 | // tag 603 | if (cap = this.rules.tag.exec(src)) { 604 | if (!this.inLink && /^/i.test(cap[0])) { 607 | this.inLink = false; 608 | } 609 | src = src.substring(cap[0].length); 610 | out += this.options.sanitize 611 | ? this.options.sanitizer 612 | ? this.options.sanitizer(cap[0]) 613 | : escape(cap[0]) 614 | : cap[0] 615 | continue; 616 | } 617 | 618 | // link 619 | if (cap = this.rules.link.exec(src)) { 620 | src = src.substring(cap[0].length); 621 | this.inLink = true; 622 | out += this.outputLink(cap, { 623 | href: cap[2], 624 | title: cap[3] 625 | }); 626 | this.inLink = false; 627 | continue; 628 | } 629 | 630 | // reflink, nolink 631 | if ((cap = this.rules.reflink.exec(src)) 632 | || (cap = this.rules.nolink.exec(src))) { 633 | src = src.substring(cap[0].length); 634 | link = (cap[2] || cap[1]).replace(/\s+/g, ' '); 635 | link = this.links[link.toLowerCase()]; 636 | if (!link || !link.href) { 637 | out += cap[0].charAt(0); 638 | src = cap[0].substring(1) + src; 639 | continue; 640 | } 641 | this.inLink = true; 642 | out += this.outputLink(cap, link); 643 | this.inLink = false; 644 | continue; 645 | } 646 | 647 | // strong 648 | if (cap = this.rules.strong.exec(src)) { 649 | src = src.substring(cap[0].length); 650 | out += this.renderer.strong(this.output(cap[2] || cap[1])); 651 | continue; 652 | } 653 | 654 | // em 655 | if (cap = this.rules.em.exec(src)) { 656 | src = src.substring(cap[0].length); 657 | out += this.renderer.em(this.output(cap[2] || cap[1])); 658 | continue; 659 | } 660 | 661 | // code 662 | if (cap = this.rules.code.exec(src)) { 663 | src = src.substring(cap[0].length); 664 | out += this.renderer.codespan(escape(cap[2], true)); 665 | continue; 666 | } 667 | 668 | // br 669 | if (cap = this.rules.br.exec(src)) { 670 | src = src.substring(cap[0].length); 671 | out += this.renderer.br(); 672 | continue; 673 | } 674 | 675 | // del (gfm) 676 | if (cap = this.rules.del.exec(src)) { 677 | src = src.substring(cap[0].length); 678 | out += this.renderer.del(this.output(cap[1])); 679 | continue; 680 | } 681 | 682 | // text 683 | if (cap = this.rules.text.exec(src)) { 684 | src = src.substring(cap[0].length); 685 | out += this.renderer.text(escape(this.smartypants(cap[0]))); 686 | continue; 687 | } 688 | 689 | if (src) { 690 | throw new 691 | Error('Infinite loop on byte: ' + src.charCodeAt(0)); 692 | } 693 | } 694 | 695 | return out; 696 | }; 697 | 698 | /** 699 | * Compile Link 700 | */ 701 | 702 | InlineLexer.prototype.outputLink = function(cap, link) { 703 | var href = escape(link.href) 704 | , title = link.title ? escape(link.title) : null; 705 | 706 | return cap[0].charAt(0) !== '!' 707 | ? this.renderer.link(href, title, this.output(cap[1])) 708 | : this.renderer.image(href, title, escape(cap[1])); 709 | }; 710 | 711 | /** 712 | * Smartypants Transformations 713 | */ 714 | 715 | InlineLexer.prototype.smartypants = function(text) { 716 | if (!this.options.smartypants) return text; 717 | return text 718 | // em-dashes 719 | .replace(/---/g, '\u2014') 720 | // en-dashes 721 | .replace(/--/g, '\u2013') 722 | // opening singles 723 | .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018') 724 | // closing singles & apostrophes 725 | .replace(/'/g, '\u2019') 726 | // opening doubles 727 | .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c') 728 | // closing doubles 729 | .replace(/"/g, '\u201d') 730 | // ellipses 731 | .replace(/\.{3}/g, '\u2026'); 732 | }; 733 | 734 | /** 735 | * Mangle Links 736 | */ 737 | 738 | InlineLexer.prototype.mangle = function(text) { 739 | if (!this.options.mangle) return text; 740 | var out = '' 741 | , l = text.length 742 | , i = 0 743 | , ch; 744 | 745 | for (; i < l; i++) { 746 | ch = text.charCodeAt(i); 747 | if (Math.random() > 0.5) { 748 | ch = 'x' + ch.toString(16); 749 | } 750 | out += '&#' + ch + ';'; 751 | } 752 | 753 | return out; 754 | }; 755 | 756 | /** 757 | * Renderer 758 | */ 759 | 760 | function Renderer(options) { 761 | this.options = options || {}; 762 | } 763 | 764 | Renderer.prototype.code = function(code, lang, escaped) { 765 | if (this.options.highlight) { 766 | var out = this.options.highlight(code, lang); 767 | if (out != null && out !== code) { 768 | escaped = true; 769 | code = out; 770 | } 771 | } 772 | 773 | if (!lang) { 774 | return '
'
 775 |       + (escaped ? code : escape(code, true))
 776 |       + '\n
'; 777 | } 778 | 779 | return '
'
 783 |     + (escaped ? code : escape(code, true))
 784 |     + '\n
\n'; 785 | }; 786 | 787 | Renderer.prototype.blockquote = function(quote) { 788 | return '
\n' + quote + '
\n'; 789 | }; 790 | 791 | Renderer.prototype.html = function(html) { 792 | return html; 793 | }; 794 | 795 | Renderer.prototype.heading = function(text, level, raw) { 796 | return '' 802 | + text 803 | + '\n'; 806 | }; 807 | 808 | Renderer.prototype.hr = function() { 809 | return this.options.xhtml ? '
\n' : '
\n'; 810 | }; 811 | 812 | Renderer.prototype.list = function(body, ordered) { 813 | var type = ordered ? 'ol' : 'ul'; 814 | return '<' + type + '>\n' + body + '\n'; 815 | }; 816 | 817 | Renderer.prototype.listitem = function(text) { 818 | return '
  • ' + text + '
  • \n'; 819 | }; 820 | 821 | Renderer.prototype.paragraph = function(text) { 822 | return '

    ' + text + '

    \n'; 823 | }; 824 | 825 | Renderer.prototype.table = function(header, body) { 826 | return '\n' 827 | + '\n' 828 | + header 829 | + '\n' 830 | + '\n' 831 | + body 832 | + '\n' 833 | + '
    \n'; 834 | }; 835 | 836 | Renderer.prototype.tablerow = function(content) { 837 | return '\n' + content + '\n'; 838 | }; 839 | 840 | Renderer.prototype.tablecell = function(content, flags) { 841 | var type = flags.header ? 'th' : 'td'; 842 | var tag = flags.align 843 | ? '<' + type + ' style="text-align:' + flags.align + '">' 844 | : '<' + type + '>'; 845 | return tag + content + '\n'; 846 | }; 847 | 848 | // span level renderer 849 | Renderer.prototype.strong = function(text) { 850 | return '' + text + ''; 851 | }; 852 | 853 | Renderer.prototype.em = function(text) { 854 | return '' + text + ''; 855 | }; 856 | 857 | Renderer.prototype.codespan = function(text) { 858 | return '' + text + ''; 859 | }; 860 | 861 | Renderer.prototype.br = function() { 862 | return this.options.xhtml ? '
    ' : '
    '; 863 | }; 864 | 865 | Renderer.prototype.del = function(text) { 866 | return '' + text + ''; 867 | }; 868 | 869 | Renderer.prototype.link = function(href, title, text) { 870 | if (this.options.sanitize) { 871 | try { 872 | var prot = decodeURIComponent(unescape(href)) 873 | .replace(/[^\w:]/g, '') 874 | .toLowerCase(); 875 | } catch (e) { 876 | return ''; 877 | } 878 | if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) { 879 | return ''; 880 | } 881 | } 882 | var out = '
    '; 887 | return out; 888 | }; 889 | 890 | Renderer.prototype.image = function(href, title, text) { 891 | var out = '' + text + '' : '>'; 896 | return out; 897 | }; 898 | 899 | Renderer.prototype.text = function(text) { 900 | return text; 901 | }; 902 | 903 | /** 904 | * Parsing & Compiling 905 | */ 906 | 907 | function Parser(options) { 908 | this.tokens = []; 909 | this.token = null; 910 | this.options = options || marked.defaults; 911 | this.options.renderer = this.options.renderer || new Renderer; 912 | this.renderer = this.options.renderer; 913 | this.renderer.options = this.options; 914 | } 915 | 916 | /** 917 | * Static Parse Method 918 | */ 919 | 920 | Parser.parse = function(src, options, renderer) { 921 | var parser = new Parser(options, renderer); 922 | return parser.parse(src); 923 | }; 924 | 925 | /** 926 | * Parse Loop 927 | */ 928 | 929 | Parser.prototype.parse = function(src) { 930 | this.inline = new InlineLexer(src.links, this.options, this.renderer); 931 | this.tokens = src.reverse(); 932 | 933 | var out = ''; 934 | while (this.next()) { 935 | out += this.tok(); 936 | } 937 | 938 | return out; 939 | }; 940 | 941 | /** 942 | * Next Token 943 | */ 944 | 945 | Parser.prototype.next = function() { 946 | return this.token = this.tokens.pop(); 947 | }; 948 | 949 | /** 950 | * Preview Next Token 951 | */ 952 | 953 | Parser.prototype.peek = function() { 954 | return this.tokens[this.tokens.length - 1] || 0; 955 | }; 956 | 957 | /** 958 | * Parse Text Tokens 959 | */ 960 | 961 | Parser.prototype.parseText = function() { 962 | var body = this.token.text; 963 | 964 | while (this.peek().type === 'text') { 965 | body += '\n' + this.next().text; 966 | } 967 | 968 | return this.inline.output(body); 969 | }; 970 | 971 | /** 972 | * Parse Current Token 973 | */ 974 | 975 | Parser.prototype.tok = function() { 976 | switch (this.token.type) { 977 | case 'space': { 978 | return ''; 979 | } 980 | case 'hr': { 981 | return this.renderer.hr(); 982 | } 983 | case 'heading': { 984 | return this.renderer.heading( 985 | this.inline.output(this.token.text), 986 | this.token.depth, 987 | this.token.text); 988 | } 989 | case 'code': { 990 | return this.renderer.code(this.token.text, 991 | this.token.lang, 992 | this.token.escaped); 993 | } 994 | case 'table': { 995 | var header = '' 996 | , body = '' 997 | , i 998 | , row 999 | , cell 1000 | , flags 1001 | , j; 1002 | 1003 | // header 1004 | cell = ''; 1005 | for (i = 0; i < this.token.header.length; i++) { 1006 | flags = { header: true, align: this.token.align[i] }; 1007 | cell += this.renderer.tablecell( 1008 | this.inline.output(this.token.header[i]), 1009 | { header: true, align: this.token.align[i] } 1010 | ); 1011 | } 1012 | header += this.renderer.tablerow(cell); 1013 | 1014 | for (i = 0; i < this.token.cells.length; i++) { 1015 | row = this.token.cells[i]; 1016 | 1017 | cell = ''; 1018 | for (j = 0; j < row.length; j++) { 1019 | cell += this.renderer.tablecell( 1020 | this.inline.output(row[j]), 1021 | { header: false, align: this.token.align[j] } 1022 | ); 1023 | } 1024 | 1025 | body += this.renderer.tablerow(cell); 1026 | } 1027 | return this.renderer.table(header, body); 1028 | } 1029 | case 'blockquote_start': { 1030 | var body = ''; 1031 | 1032 | while (this.next().type !== 'blockquote_end') { 1033 | body += this.tok(); 1034 | } 1035 | 1036 | return this.renderer.blockquote(body); 1037 | } 1038 | case 'list_start': { 1039 | var body = '' 1040 | , ordered = this.token.ordered; 1041 | 1042 | while (this.next().type !== 'list_end') { 1043 | body += this.tok(); 1044 | } 1045 | 1046 | return this.renderer.list(body, ordered); 1047 | } 1048 | case 'list_item_start': { 1049 | var body = ''; 1050 | 1051 | while (this.next().type !== 'list_item_end') { 1052 | body += this.token.type === 'text' 1053 | ? this.parseText() 1054 | : this.tok(); 1055 | } 1056 | 1057 | return this.renderer.listitem(body); 1058 | } 1059 | case 'loose_item_start': { 1060 | var body = ''; 1061 | 1062 | while (this.next().type !== 'list_item_end') { 1063 | body += this.tok(); 1064 | } 1065 | 1066 | return this.renderer.listitem(body); 1067 | } 1068 | case 'html': { 1069 | var html = !this.token.pre && !this.options.pedantic 1070 | ? this.inline.output(this.token.text) 1071 | : this.token.text; 1072 | return this.renderer.html(html); 1073 | } 1074 | case 'paragraph': { 1075 | return this.renderer.paragraph(this.inline.output(this.token.text)); 1076 | } 1077 | case 'text': { 1078 | return this.renderer.paragraph(this.parseText()); 1079 | } 1080 | } 1081 | }; 1082 | 1083 | /** 1084 | * Helpers 1085 | */ 1086 | 1087 | function escape(html, encode) { 1088 | return html 1089 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') 1090 | .replace(//g, '>') 1092 | .replace(/"/g, '"') 1093 | .replace(/'/g, '''); 1094 | } 1095 | 1096 | function unescape(html) { 1097 | return html.replace(/&([#\w]+);/g, function(_, n) { 1098 | n = n.toLowerCase(); 1099 | if (n === 'colon') return ':'; 1100 | if (n.charAt(0) === '#') { 1101 | return n.charAt(1) === 'x' 1102 | ? String.fromCharCode(parseInt(n.substring(2), 16)) 1103 | : String.fromCharCode(+n.substring(1)); 1104 | } 1105 | return ''; 1106 | }); 1107 | } 1108 | 1109 | function replace(regex, opt) { 1110 | regex = regex.source; 1111 | opt = opt || ''; 1112 | return function self(name, val) { 1113 | if (!name) return new RegExp(regex, opt); 1114 | val = val.source || val; 1115 | val = val.replace(/(^|[^\[])\^/g, '$1'); 1116 | regex = regex.replace(name, val); 1117 | return self; 1118 | }; 1119 | } 1120 | 1121 | function noop() {} 1122 | noop.exec = noop; 1123 | 1124 | function merge(obj) { 1125 | var i = 1 1126 | , target 1127 | , key; 1128 | 1129 | for (; i < arguments.length; i++) { 1130 | target = arguments[i]; 1131 | for (key in target) { 1132 | if (Object.prototype.hasOwnProperty.call(target, key)) { 1133 | obj[key] = target[key]; 1134 | } 1135 | } 1136 | } 1137 | 1138 | return obj; 1139 | } 1140 | 1141 | 1142 | /** 1143 | * Marked 1144 | */ 1145 | 1146 | function marked(src, opt, callback) { 1147 | if (callback || typeof opt === 'function') { 1148 | if (!callback) { 1149 | callback = opt; 1150 | opt = null; 1151 | } 1152 | 1153 | opt = merge({}, marked.defaults, opt || {}); 1154 | 1155 | var highlight = opt.highlight 1156 | , tokens 1157 | , pending 1158 | , i = 0; 1159 | 1160 | try { 1161 | tokens = Lexer.lex(src, opt) 1162 | } catch (e) { 1163 | return callback(e); 1164 | } 1165 | 1166 | pending = tokens.length; 1167 | 1168 | var done = function(err) { 1169 | if (err) { 1170 | opt.highlight = highlight; 1171 | return callback(err); 1172 | } 1173 | 1174 | var out; 1175 | 1176 | try { 1177 | out = Parser.parse(tokens, opt); 1178 | } catch (e) { 1179 | err = e; 1180 | } 1181 | 1182 | opt.highlight = highlight; 1183 | 1184 | return err 1185 | ? callback(err) 1186 | : callback(null, out); 1187 | }; 1188 | 1189 | if (!highlight || highlight.length < 3) { 1190 | return done(); 1191 | } 1192 | 1193 | delete opt.highlight; 1194 | 1195 | if (!pending) return done(); 1196 | 1197 | for (; i < tokens.length; i++) { 1198 | (function(token) { 1199 | if (token.type !== 'code') { 1200 | return --pending || done(); 1201 | } 1202 | return highlight(token.text, token.lang, function(err, code) { 1203 | if (err) return done(err); 1204 | if (code == null || code === token.text) { 1205 | return --pending || done(); 1206 | } 1207 | token.text = code; 1208 | token.escaped = true; 1209 | --pending || done(); 1210 | }); 1211 | })(tokens[i]); 1212 | } 1213 | 1214 | return; 1215 | } 1216 | try { 1217 | if (opt) opt = merge({}, marked.defaults, opt); 1218 | return Parser.parse(Lexer.lex(src, opt), opt); 1219 | } catch (e) { 1220 | e.message += '\nPlease report this to https://github.com/chjj/marked.'; 1221 | if ((opt || marked.defaults).silent) { 1222 | return '

    An error occured:

    '
    1223 |         + escape(e.message + '', true)
    1224 |         + '
    '; 1225 | } 1226 | throw e; 1227 | } 1228 | } 1229 | 1230 | /** 1231 | * Options 1232 | */ 1233 | 1234 | marked.options = 1235 | marked.setOptions = function(opt) { 1236 | merge(marked.defaults, opt); 1237 | return marked; 1238 | }; 1239 | 1240 | marked.defaults = { 1241 | gfm: true, 1242 | tables: true, 1243 | breaks: false, 1244 | pedantic: false, 1245 | sanitize: false, 1246 | sanitizer: null, 1247 | mangle: true, 1248 | smartLists: false, 1249 | silent: false, 1250 | highlight: null, 1251 | langPrefix: 'lang-', 1252 | smartypants: false, 1253 | headerPrefix: '', 1254 | renderer: new Renderer, 1255 | xhtml: false 1256 | }; 1257 | 1258 | /** 1259 | * Expose 1260 | */ 1261 | 1262 | marked.Parser = Parser; 1263 | marked.parser = Parser.parse; 1264 | 1265 | marked.Renderer = Renderer; 1266 | 1267 | marked.Lexer = Lexer; 1268 | marked.lexer = Lexer.lex; 1269 | 1270 | marked.InlineLexer = InlineLexer; 1271 | marked.inlineLexer = InlineLexer.output; 1272 | 1273 | marked.parse = marked; 1274 | 1275 | if (typeof module !== 'undefined' && typeof exports === 'object') { 1276 | module.exports = marked; 1277 | } else if (typeof define === 'function' && define.amd) { 1278 | define(function() { return marked; }); 1279 | } else { 1280 | this.marked = marked; 1281 | } 1282 | 1283 | }).call(function() { 1284 | return this || (typeof window !== 'undefined' ? window : global); 1285 | }()); 1286 | -------------------------------------------------------------------------------- /markedview/src/main/assets/html/js/md_preview.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | var rend = new marked.Renderer(); 4 | 5 | marked.setOptions({ 6 | langPrefix: '', 7 | highlight: function(code){ 8 | return hljs.highlightAuto(code).value; 9 | } 10 | }); 11 | 12 | rend.code = function(code, lang, escaped){ 13 | var lineArray = code.split(/\r\n|\r|\n/); 14 | var len = 0; 15 | if(lineArray == null){ 16 | len = code.length; 17 | 18 | }else{ 19 | $.each(lineArray, function(index, val){ 20 | if(len < val.length){ 21 | len = val.length; 22 | } 23 | }); 24 | } 25 | 26 | var code = code.replace(/&/g, '&') 27 | .replace(//g, '>') 29 | .replace(/"/g, '"') 30 | .replace(/'/g, '''); 31 | 32 | if(!lang){ 33 | return '
    '
     38 |                 + code
     39 |                 + '\n
    '; 40 | } 41 | 42 | return '
    '
     49 |             + code
     50 |             + '\n
    '; 51 | }; 52 | 53 | function escSub(text){ 54 | var result = text.match(/~+.*?~+/g); 55 | if(result == null){ 56 | return text; 57 | } 58 | 59 | $.each(result, function(index, val){ 60 | if(val.lastIndexOf('~~', 0) === 0){ 61 | return true; 62 | } 63 | var escapedText = val.replace(/~/, ''); 64 | escapedText = escapedText.replace(/~/, ''); 65 | var reg = new RegExp(val, 'g'); 66 | text = text.replace(reg, escapedText); 67 | }); 68 | 69 | return text; 70 | } 71 | 72 | function escSup(text){ 73 | var result = text.match(/\^.*?\^/g); 74 | if(result == null){ 75 | return text; 76 | } 77 | 78 | $.each(result, function(index, val){ 79 | var escapedText = val.replace(/\^/, ''); 80 | escapedText = escapedText.replace(/\^/, ''); 81 | val = val.replace(/\^/g, '\\^'); 82 | var reg = new RegExp(val, 'g'); 83 | text = text.replace(reg, escapedText); 84 | }); 85 | 86 | return text; 87 | } 88 | 89 | preview = function setMarkdown(md_text, codeScrollDisable){ 90 | if(md_text == ""){ 91 | return false; 92 | } 93 | 94 | md_text = md_text.replace(/\\n/g, "\n"); 95 | md_text = escSub(md_text); 96 | md_text = escSup(md_text); 97 | 98 | // markdown html 99 | var md_html; 100 | if(codeScrollDisable){ 101 | md_html = marked(md_text); 102 | }else{ 103 | md_html = marked(md_text, {renderer: rend}); 104 | } 105 | 106 | $('#preview').html(md_html); 107 | 108 | $('pre code').each(function(i, block){ 109 | hljs.highlightBlock(block); 110 | }); 111 | }; 112 | }); -------------------------------------------------------------------------------- /markedview/src/main/assets/html/md_preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 |
    20 | 21 | 22 | -------------------------------------------------------------------------------- /markedview/src/main/java/com/mittsu/markedview/MarkedView.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedview; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.annotation.TargetApi; 5 | import android.content.Context; 6 | import android.os.Build; 7 | import android.util.AttributeSet; 8 | import android.util.Base64; 9 | import android.util.Log; 10 | import android.webkit.WebSettings; 11 | import android.webkit.WebView; 12 | import android.webkit.WebViewClient; 13 | 14 | import java.io.BufferedInputStream; 15 | import java.io.BufferedReader; 16 | import java.io.File; 17 | import java.io.FileInputStream; 18 | import java.io.FileNotFoundException; 19 | import java.io.IOException; 20 | import java.io.InputStreamReader; 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | /** 25 | * The MarkedView is the Markdown viewer. 26 | * 27 | * Created by mittsu on 2016/04/25. 28 | */ 29 | public final class MarkedView extends WebView { 30 | 31 | private static final String TAG = MarkedView.class.getSimpleName(); 32 | private static final String IMAGE_PATTERN = "!\\[(.*)\\]\\((.*)\\)"; 33 | 34 | private String previewText; 35 | private boolean codeScrollDisable; 36 | 37 | public MarkedView(Context context) { 38 | this(context, null); 39 | } 40 | 41 | public MarkedView(Context context, AttributeSet attrs) { 42 | this(context, attrs, 0); 43 | } 44 | 45 | public MarkedView(Context context, AttributeSet attrs, int defStyleAttr) { 46 | super(context, attrs, defStyleAttr); 47 | init(); 48 | } 49 | 50 | @TargetApi(11) 51 | @SuppressLint("SetJavaScriptEnabled") 52 | private void init(){ 53 | // default browser is not called. 54 | setWebViewClient(new WebViewClient(){ 55 | public void onPageFinished(WebView view, String url){ 56 | sendScriptAction(); 57 | } 58 | }); 59 | 60 | loadUrl("file:///android_asset/html/md_preview.html"); 61 | 62 | getSettings().setJavaScriptEnabled(true); 63 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 64 | getSettings().setAllowUniversalAccessFromFileURLs(true); 65 | } 66 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 67 | getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); 68 | } 69 | } 70 | 71 | private void sendScriptAction() { 72 | if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { 73 | loadUrl(previewText); 74 | } else { 75 | evaluateJavascript(previewText, null); 76 | } 77 | } 78 | 79 | /** load Markdown text from file path. **/ 80 | public void loadMDFilePath(String filePath){ 81 | loadMDFile(new File(filePath)); 82 | } 83 | 84 | /** load Markdown text from file. **/ 85 | public void loadMDFile(File file){ 86 | String mdText = ""; 87 | try { 88 | FileInputStream fileInputStream = new FileInputStream(file); 89 | 90 | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream); 91 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 92 | 93 | String readText = ""; 94 | StringBuilder stringBuilder = new StringBuilder(); 95 | while ((readText = bufferedReader.readLine()) != null) { 96 | stringBuilder.append(readText); 97 | stringBuilder.append("\n"); 98 | } 99 | fileInputStream.close(); 100 | mdText = stringBuilder.toString(); 101 | 102 | } catch(FileNotFoundException e) { 103 | Log.e(TAG, "FileNotFoundException:" + e); 104 | } catch(IOException e) { 105 | Log.e(TAG, "IOException:" + e); 106 | } 107 | setMDText(mdText); 108 | } 109 | 110 | /** set show the Markdown text. **/ 111 | public void setMDText(String text){ 112 | text2Mark(text); 113 | } 114 | 115 | private void text2Mark(String mdText){ 116 | 117 | String bs64MdText = imgToBase64(mdText); 118 | String escMdText = escapeForText(bs64MdText); 119 | 120 | if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { 121 | previewText = String.format("javascript:preview('%s', %b)", escMdText, isCodeScrollDisable()); 122 | 123 | } else { 124 | previewText = String.format("preview('%s', %b)", escMdText, isCodeScrollDisable()); 125 | } 126 | sendScriptAction(); 127 | } 128 | 129 | private String escapeForText(String mdText){ 130 | String escText = mdText.replace("\n", "\\\\n"); 131 | escText = escText.replace("'", "\\\'"); 132 | //in some cases the string may have "\r" and our view will show nothing,so replace it 133 | escText = escText.replace("\r",""); 134 | return escText; 135 | } 136 | 137 | private String imgToBase64(String mdText){ 138 | Pattern ptn = Pattern.compile(IMAGE_PATTERN); 139 | Matcher matcher = ptn.matcher(mdText); 140 | if(!matcher.find()){ 141 | return mdText; 142 | } 143 | 144 | String imgPath = matcher.group(2); 145 | if(isUrlPrefix(imgPath) || !isPathExChack(imgPath)) { 146 | return mdText; 147 | } 148 | String baseType = imgEx2BaseType(imgPath); 149 | if(baseType.equals("")){ 150 | // image load error. 151 | return mdText; 152 | } 153 | 154 | File file = new File(imgPath); 155 | byte[] bytes = new byte[(int) file.length()]; 156 | try { 157 | BufferedInputStream buf = new BufferedInputStream(new FileInputStream(file)); 158 | buf.read(bytes, 0, bytes.length); 159 | buf.close(); 160 | } catch (FileNotFoundException e) { 161 | Log.e(TAG, "FileNotFoundException:" + e); 162 | } catch (IOException e) { 163 | Log.e(TAG, "IOException:" + e); 164 | } 165 | String base64Img = baseType + Base64.encodeToString(bytes, Base64.NO_WRAP); 166 | 167 | return mdText.replace(imgPath, base64Img); 168 | } 169 | 170 | private boolean isUrlPrefix(String text){ 171 | return text.startsWith("http://") || text.startsWith("https://"); 172 | } 173 | 174 | private boolean isPathExChack(String text){ 175 | return text.endsWith(".png") 176 | || text.endsWith(".jpg") 177 | || text.endsWith(".jpeg") 178 | || text.endsWith(".gif"); 179 | } 180 | 181 | private String imgEx2BaseType(String text){ 182 | if(text.endsWith(".png")){ 183 | return "data:image/png;base64,"; 184 | }else if(text.endsWith(".jpg") || text.endsWith(".jpeg")){ 185 | return "data:image/jpg;base64,"; 186 | }else if(text.endsWith(".gif")){ 187 | return "data:image/gif;base64,"; 188 | }else{ 189 | return ""; 190 | } 191 | } 192 | 193 | 194 | /* options */ 195 | 196 | public void setCodeScrollDisable(){ 197 | codeScrollDisable = true; 198 | } 199 | 200 | private boolean isCodeScrollDisable(){ 201 | return codeScrollDisable; 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /markedview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MarkedView 3 | 4 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.mittsu.markedviewlib" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | sourceSets{ 22 | main{ 23 | assets.srcDirs = ['src/main/assets'] 24 | } 25 | } 26 | } 27 | 28 | dependencies { 29 | compile fileTree(dir: 'libs', include: ['*.jar']) 30 | testCompile 'junit:junit:4.12' 31 | compile 'com.android.support:appcompat-v7:23.1.1' 32 | compile project(':markedview') 33 | } 34 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/mittu/Developer/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/mittsu/markedviewlib/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedviewlib; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | *
    Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/assets/sample_data/sample.md: -------------------------------------------------------------------------------- 1 | ## MarkedView Example 2 | --- 3 | 4 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MarkedView-green.svg?style=true)](https://android-arsenal.com/details/1/3801) 5 | [![License](https://img.shields.io/badge/license-MIT-green.svg)]() 6 | [![Platform](https://img.shields.io/badge/platform-Android-green.svg) ]() 7 | [![Download](https://api.bintray.com/packages/mittsuu/maven/markedview/images/download.svg) ](https://bintray.com/mittsuu/maven/markedview/_latestVersion) 8 | 9 | 10 | ![sample_sc](http://tk2-212-15794.vs.sakura.ne.jp/sample/oss-imgs/marked-sample-img.png) 11 | 12 | 13 | ## Introduction 14 | --- 15 | 16 | The MarkedView is the markdown text viewer. 17 | 18 | 19 | ## Usage 20 | --- 21 | 22 | It is a simple module, which enable you to convert any files into initialized view. 23 | 24 | 25 | ```xml 26 | // xml 27 | 31 | 32 | ``` 33 | 34 | 35 | ```java 36 | // Java code 37 | 38 | import com.mittsu.markedview.MarkedView; 39 | 40 | ・・・ 41 | 42 | // call from xml 43 | MarkedView mdView = (MarkedView)findViewById(R.id.md_view); 44 | // call from code 45 | // MarkedView mdView = new MarkedView(this); 46 | 47 | // set markdown text pattern. ('contents' object is markdown text) 48 | mdView.setMDText(contents); 49 | 50 | // load Markdown file pattern. 51 | // mdView.loadFile(filePath) 52 | 53 | ``` 54 | 55 | 56 | ```java 57 | /* option */ 58 | 59 | // code block in scrolling be deactivated. 60 | mdView.setCodeScrollDisable(); 61 | 62 | ``` 63 | 64 | 65 | ## Installation 66 | --- 67 | 68 | Add the dependency 69 | 70 | ```gradle 71 | dependencies { 72 | compile 'com.mittsu:markedview:1.0.4@aar' 73 | } 74 | ``` 75 | 76 | ## See Also 77 | --- 78 | 79 | * MarkedView-for-iOS 80 | https://github.com/mittsuu/MarkedView-for-iOS 81 | 82 | 83 | ## Credits 84 | --- 85 | 86 | This used the following open source components. 87 | 88 | [Marked](https://github.com/chjj/marked) : Markdown parser written in JavaScript 89 | 90 | [highlight.js](https://highlightjs.org/) : Syntax highlighting for the Web 91 | 92 | 93 | ## License 94 | --- 95 | 96 | MarkedView is available under the MIT license. See the LICENSE file for more info. 97 | -------------------------------------------------------------------------------- /sample/src/main/java/com/mittsu/markedviewlib/FileCopyManager.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedviewlib; 2 | 3 | import android.content.Context; 4 | import android.content.res.AssetManager; 5 | import android.util.Log; 6 | 7 | import java.io.BufferedInputStream; 8 | import java.io.BufferedOutputStream; 9 | import java.io.FileNotFoundException; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.OutputStream; 14 | 15 | /** 16 | * Created by mittsu on 2016/05/23. 17 | * assets copy to app directory. 18 | */ 19 | public final class FileCopyManager { 20 | 21 | private static final String TAG = FileCopyManager.class.getSimpleName(); 22 | 23 | public FileCopyManager(Context c){ 24 | copyAsset2AppDir(c); 25 | } 26 | 27 | public String getSampleFilePath(Context c){ 28 | return c.getFilesDir() + "/sample.md"; 29 | } 30 | 31 | private void copyAsset2AppDir(Context c){ 32 | String[] asFiles = new String[]{}; 33 | AssetManager am = c.getResources().getAssets(); 34 | 35 | try{ 36 | asFiles = am.list("sample_data"); 37 | }catch(IOException e){ 38 | Log.e(TAG, "get file from assets error.\n" + e); 39 | } 40 | 41 | for(String file : asFiles){ 42 | 43 | BufferedInputStream inputStream = null; 44 | BufferedOutputStream outStream = null; 45 | 46 | try{ 47 | inputStream = new BufferedInputStream(am.open("sample_data/" + file)); 48 | FileOutputStream saveFile = c.openFileOutput(file, Context.MODE_PRIVATE); 49 | outStream = new BufferedOutputStream(saveFile); 50 | 51 | copyFile(inputStream, outStream); 52 | 53 | } catch (FileNotFoundException e) { 54 | Log.e(TAG, "FileNotFoundException:" + e); 55 | } catch (IOException e) { 56 | Log.e(TAG, "IOException:" + e); 57 | } finally { 58 | streamClose(inputStream, outStream); 59 | } 60 | } 61 | } 62 | 63 | private void copyFile(InputStream in, OutputStream out) throws IOException { 64 | byte[] buffer = new byte[1024 * 1024]; 65 | int read; 66 | while((read = in.read(buffer)) != -1){ 67 | out.write(buffer, 0, read); 68 | } 69 | } 70 | 71 | private void streamClose(InputStream in, OutputStream out){ 72 | try { 73 | if(in != null) in.close(); 74 | if(out != null) out.close(); 75 | } catch (IOException e) { 76 | Log.e(TAG, "IOException:" + e); 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /sample/src/main/java/com/mittsu/markedviewlib/LiveReviewFragment.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedviewlib; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.text.Editable; 6 | import android.text.TextWatcher; 7 | import android.util.Log; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.EditText; 12 | 13 | import com.mittsu.markedview.MarkedView; 14 | 15 | public final class LiveReviewFragment extends Fragment { 16 | 17 | private final String TAG = this.getClass().getSimpleName(); 18 | 19 | @Override 20 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 21 | Bundle savedInstanceState) { 22 | View view = inflater.inflate(R.layout.frag_live_preview, container, false); 23 | 24 | final MarkedView markedView = (MarkedView) view.findViewById(R.id.live_md_view); 25 | final EditText edit = (EditText) view.findViewById(R.id.edit_text); 26 | edit.addTextChangedListener(new TextWatcher() { 27 | 28 | @Override 29 | public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {} 30 | 31 | @Override 32 | public void onTextChanged(CharSequence charSequence, int start, int before, int count) {} 33 | 34 | @Override 35 | public void afterTextChanged(Editable editable) { 36 | String markdownText = editable.toString(); 37 | Log.d(TAG, markdownText); 38 | markedView.setMDText(markdownText); 39 | } 40 | }); 41 | 42 | edit.setText(R.string.live_view_example_text); 43 | 44 | return view; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /sample/src/main/java/com/mittsu/markedviewlib/LoadFileFragment.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedviewlib; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.mittsu.markedview.MarkedView; 10 | 11 | import java.io.File; 12 | 13 | public final class LoadFileFragment extends Fragment { 14 | 15 | @Override 16 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 17 | Bundle savedInstanceState) { 18 | View view = inflater.inflate(R.layout.frag_load_mdfile, container, false); 19 | 20 | FileCopyManager fcm = new FileCopyManager(getActivity()); 21 | MarkedView mdView = (MarkedView)view.findViewById(R.id.md_view); 22 | // code block in scrolling be deactivated. 23 | // mdView.setCodeScrollDisable(); 24 | 25 | File mdFile = new File(fcm.getSampleFilePath(getActivity())); 26 | mdView.loadMDFile(mdFile); 27 | 28 | return view; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sample/src/main/java/com/mittsu/markedviewlib/SampleActivity.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedviewlib; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentTransaction; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | 10 | public class SampleActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_sample); 16 | 17 | FragmentManager fm = getSupportFragmentManager(); 18 | FragmentTransaction ft = fm.beginTransaction(); 19 | ft.replace(R.id.container, new LoadFileFragment()); 20 | ft.commit(); 21 | } 22 | 23 | @Override 24 | public boolean onCreateOptionsMenu(Menu menu) { 25 | getMenuInflater().inflate(R.menu.option, menu); 26 | return true; 27 | } 28 | 29 | @Override 30 | public boolean onOptionsItemSelected(MenuItem item) { 31 | FragmentManager fm = getSupportFragmentManager(); 32 | FragmentTransaction ft = fm.beginTransaction(); 33 | 34 | switch (item.getItemId()) { 35 | case R.id.load_file: 36 | ft.replace(R.id.container, new LoadFileFragment()); 37 | break; 38 | case R.id.live_render: 39 | ft.replace(R.id.container, new LiveReviewFragment()); 40 | break; 41 | } 42 | ft.commit(); 43 | 44 | return super.onOptionsItemSelected(item); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/frag_live_preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/frag_load_mdfile.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/option.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Load file 4 | Live rendering 5 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MarkedViewLib 3 | Load file 4 | Live rendering 5 | 6 | 7 | # Title\n\n 8 | text\n 9 | \n\n 10 | * list\n 11 | " "* list\n 12 | " "* list\n 13 | \n\n" " 14 | [Example Link](sample)\n 15 | \n 16 | > text\n 17 | \n 18 | ~~cross off~~\n\n 19 | text^sup^\n 20 | text~sub~\n\n 21 | \n 22 | ## Tables\n 23 | ---\n\n 24 | | right | left | center |\n 25 | | --: | :-- | :--: |\n 26 | | column | column | column |\n 27 | | right | left | center |\n 28 | | be | be | be |\n 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/com/mittsu/markedviewlib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.mittsu.markedviewlib; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /sample_img/sample-lr1809170821.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample_img/sample-lr1809170821.png -------------------------------------------------------------------------------- /sample_img/sample-sc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mittsu333/MarkedView-for-Android/deadb8e3d472faa18ddeefa57ebd3f2cb5564c98/sample_img/sample-sc.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':markedview' 2 | --------------------------------------------------------------------------------