Merge branch '0.9.1-dev'

This commit is contained in:
Erik C. Thauvin 2022-08-25 14:14:31 -07:00
commit fba34f80ce
33 changed files with 714 additions and 434 deletions

View file

@ -30,11 +30,11 @@ defaults_gradle: &defaults_gradle
path: build/reports/
jobs:
build_gradle_jdk14:
build_gradle_jdk17:
<<: *defaults
docker:
- image: openjdk:14-jdk
- image: cimg/openjdk:17.0
<<: *defaults_gradle
@ -42,7 +42,7 @@ jobs:
<<: *defaults
docker:
- image: circleci/openjdk:8-jdk
- image: cimg/openjdk:8.0
<<: *defaults_gradle
@ -51,4 +51,4 @@ workflows:
gradle:
jobs:
- build_gradle_jdk8
- build_gradle_jdk14
- build_gradle_jdk17

View file

@ -1,4 +1,4 @@
name: Java CI with Gradle
name: gradle-ci
on: [push, pull_request, workflow_dispatch]
@ -6,13 +6,56 @@ jobs:
build:
runs-on: ubuntu-latest
env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m"
SONAR_JDK: "11"
strategy:
matrix:
java-version: [ 1.8, 11, 17 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: ${{ matrix.java-version }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Cache SonarCloud packages
if: matrix.java-version == env.SONAR_JDK
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-${{ matrix.java-version }}-
- name: Test with Gradle
run: ./gradlew check
run: ./gradlew build check --stacktrace
- name: SonarCloud
if: success() && matrix.java-version == env.SONAR_JDK
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonarqube
- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties

1
.gitignore vendored
View file

@ -47,6 +47,7 @@
/**/.idea/**/uiDesigner.xml
/**/.idea/**/usage.statistics.xml
/**/.idea/**/workspace.xml
/**/.idea/sonarlint*
/**/.idea_modules/
Thumbs.db
__pycache__

View file

@ -1,4 +1,4 @@
image: gradle:alpine
image: gradle:7-jdk11
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
@ -12,7 +12,7 @@ stages:
build:
stage: build
script: ./gradlew --build-cache assemble
script: gradle --build-cache assemble
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
@ -22,7 +22,7 @@ build:
test:
stage: test
script: ./gradlew check
script: gradle check
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull

19
.idea/codeStyles/Project.xml generated Normal file
View file

@ -0,0 +1,19 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="false" />
<package name="io.ktor" alias="false" withSubpackages="false" />
</value>
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View file

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View file

@ -1,6 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="&amp;#36;file.fileName&#10;&#10;Copyright (c) &amp;#36;today.year, Erik C. Thauvin (erik@thauvin.net)&#10;All rights reserved.&#10;&#10;Redistribution and use in source and binary forms, with or without&#10;modification, are permitted provided that the following conditions are met:&#10;&#10; Redistributions of source code must retain the above copyright notice, this&#10; list of conditions and the following disclaimer.&#10;&#10; Redistributions in binary form must reproduce the above copyright notice,&#10; this list of conditions and the following disclaimer in the documentation&#10; and/or other materials provided with the distribution.&#10;&#10; Neither the name of this project nor the names of its contributors may be&#10; used to endorse or promote products derived from this software without&#10; specific prior written permission.&#10;&#10;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;&#10;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&#10;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE&#10;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE&#10;FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL&#10;DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR&#10;SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER&#10;CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,&#10;OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE&#10;OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
<option name="notice" value="&amp;#36;file.fileName&#10;&#10;Copyright (c) 2020-&amp;#36;today.year, Erik C. Thauvin (erik@thauvin.net)&#10;All rights reserved.&#10;&#10;Redistribution and use in source and binary forms, with or without&#10;modification, are permitted provided that the following conditions are met:&#10;&#10; Redistributions of source code must retain the above copyright notice, this&#10; list of conditions and the following disclaimer.&#10;&#10; Redistributions in binary form must reproduce the above copyright notice,&#10; this list of conditions and the following disclaimer in the documentation&#10; and/or other materials provided with the distribution.&#10;&#10; Neither the name of this project nor the names of its contributors may be&#10; used to endorse or promote products derived from this software without&#10; specific prior written permission.&#10;&#10;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;&#10;AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&#10;IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE&#10;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE&#10;FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL&#10;DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR&#10;SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER&#10;CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,&#10;OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE&#10;OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
<option name="myName" value="Erik's Copyright Notice" />
</copyright>
</component>

View file

@ -21,5 +21,20 @@
<option name="name" value="MavenLocal" />
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenLocal" />
<option name="name" value="MavenLocal" />
<option name="url" value="file:$PROJECT_DIR$/../../maven/repository/" />
</remote-repository>
</component>
</project>

6
.idea/kotlinc.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.7.10" />
</component>
</project>

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="libraries-with-intellij-classes">
<option name="intellijApiContainingLibraries">
<list>
<LibraryCoordinatesState>
<option name="artifactId" value="ideaIU" />
<option name="groupId" value="com.jetbrains.intellij.idea" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="ideaIU" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="ideaIC" />
<option name="groupId" value="com.jetbrains.intellij.idea" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="ideaIC" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="pycharmPY" />
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="pycharmPY" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="pycharmPC" />
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="pycharmPC" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="clion" />
<option name="groupId" value="com.jetbrains.intellij.clion" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="clion" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="riderRD" />
<option name="groupId" value="com.jetbrains.intellij.rider" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="riderRD" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="goland" />
<option name="groupId" value="com.jetbrains.intellij.goland" />
</LibraryCoordinatesState>
<LibraryCoordinatesState>
<option name="artifactId" value="goland" />
<option name="groupId" value="com.jetbrains" />
</LibraryCoordinatesState>
</list>
</option>
</component>
</project>

2
.idea/misc.xml generated
View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="false" project-jdk-name="14" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="15" project-jdk-type="JavaSDK" />
</project>

View file

@ -1,26 +0,0 @@
language: java
dist: trusty
env:
global:
- CI=true
#install:
# - git fetch --unshallow --tags
addons:
sonarcloud:
organization: "ethauvin-github"
jdk:
- oraclejdk8
- openjdk15
before_install:
- chmod +x gradlew
after_success:
- |
if [ "${TRAVIS_TEST_RESULT}" == 0 ] && [ "$TRAVIS_JDK_VERSION" == "openjdk15" ]; then
./gradlew sonarqube
fi

View file

@ -1,4 +1,4 @@
Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,6 +1,6 @@
[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](http://opensource.org/licenses/BSD-3-Clause) [![Release](https://img.shields.io/github/release/ethauvin/readingtime.svg)](https://github.com/ethauvin/readingtime/releases/latest) [![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/readingtime.svg?label=maven%20central)](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22readingtime%22)
[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause) [![Release](https://img.shields.io/github/release/ethauvin/readingtime.svg)](https://github.com/ethauvin/readingtime/releases/latest) [![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/readingtime.svg?label=maven%20central)](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22readingtime%22)
[![Known Vulnerabilities](https://snyk.io/test/github/ethauvin/readingtime/badge.svg?targetFile=pom.xml)](https://snyk.io/test/github/ethauvin/readingtime?targetFile=pom.xml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_readingtime&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_readingtime) [![Build Status](https://travis-ci.com/ethauvin/readingtime.svg?branch=master)](https://travis-ci.com/ethauvin/readingtime) [![CircleCI](https://circleci.com/gh/ethauvin/readingtime/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/readingtime/tree/master)
[![Known Vulnerabilities](https://snyk.io/test/github/ethauvin/readingtime/badge.svg?targetFile=pom.xml)](https://snyk.io/test/github/ethauvin/readingtime?targetFile=pom.xml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_readingtime&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_readingtime) [![GitHub CI](https://github.com/ethauvin/readingtime/actions/workflows/gradle.yml/badge.svg)](https://github.com/ethauvin/readingtime/actions/workflows/gradle.yml) [![CircleCI](https://circleci.com/gh/ethauvin/readingtime/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/readingtime/tree/master)
# Estimated Reading Time for Blog Posts, Articles, etc.
@ -22,7 +22,17 @@ To get the estimated reading time in seconds use the `calcReadingTimeInSec()` fu
- View [Kotlin](https://github.com/ethauvin/readingtime/blob/master/examples/src/main/kotlin/com/example/ReadingTimeExample.kt) or [Java](https://github.com/ethauvin/readingtime/blob/master/examples/src/main/java/com/example/ReadingTimeSample.java) Examples.
### Gradle, Maven, etc.
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/build.gradle.kts) file:
```gradle
dependencies {
implementation("net.thauvin.erik:readingtime:0.9.1")
}
```
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/readingtime/0.9.0/jar).
### Properties
@ -30,24 +40,26 @@ The following properties are available:
```kotlin
ReadingTime(
text = "some_text",
text,
wpm = 275,
postfix = "min read",
plural = "min read",
excludeImages = false,
extra = 0
extra = 0,
roundingMode = RoundingMode.HALF_EVEN
)
```
Property | Description
:-------------------------- |:-------------------------------------------------------------------
`text` | The text to be evaluated.
Property | Description
:-------------------------- |:-----------------------------------------------------------------------------------------------------------------------
`text` | The text to be evaluated. (Required)
`wpm` | The words per minute reading average.
`postfix` | The value to be appended to the reading time.
`plural` | The value to be appended if the reading time is more than 1 minute.
`excludeImages` | Images are excluded from the reading time when set.
`extra` | Additional seconds to be added to the total reading time.
`roundingMode` | The [rounding mode](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/RoundingMode.html) to apply.
### Functions
@ -73,15 +85,3 @@ A JSP tag is also available for easy incorporation into web applications:
```
None of the attributes are required.
### Gradle, Maven, etc.
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/build.gradle.kts) file:
```gradle
dependencies {
implementation("net.thauvin.erik:readingtime:0.9.0")
}
```
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/readingtime/0.9.0/jar).

View file

@ -1,23 +1,24 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id("com.github.ben-manes.versions") version "0.38.0"
id("io.gitlab.arturbosch.detekt") version "1.16.0"
id("org.jetbrains.dokka") version "1.4.30"
id("org.jetbrains.kotlin.jvm") version "1.4.30"
id("org.sonarqube") version "3.1.1"
`java-library`
`maven-publish`
jacoco
signing
id("com.github.ben-manes.versions") version "0.42.0"
id("io.gitlab.arturbosch.detekt") version "1.21.0"
id("java-library")
id("java")
id("maven-publish")
id("org.jetbrains.dokka") version "1.7.10"
id("org.jetbrains.kotlinx.kover") version "0.6.0"
id("org.sonarqube") version "3.4.0.2513"
id("signing")
kotlin("jvm") version "1.7.10"
}
description = "Estimated Reading Time for Blog Posts, Articles, etc."
group = "net.thauvin.erik"
version = "0.9.0"
version = "0.9.1-SNAPSHOT"
val deployDir = "deploy"
val gitHub = "ethauvin/$name"
@ -27,14 +28,16 @@ var isRelease = "release" in gradle.startParameter.taskNames
repositories {
mavenCentral()
jcenter()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}
dependencies {
implementation("org.jsoup:jsoup:1.13.1")
implementation(platform(kotlin("bom")))
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
implementation("org.jsoup:jsoup:1.15.3")
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit"))
}
java {
@ -44,13 +47,17 @@ java {
}
detekt {
//toolVersion = "main-SNAPSHOT"
baseline = project.rootDir.resolve("config/detekt/baseline.xml")
}
sonarqube {
properties {
property("sonar.projectKey", "ethauvin_$name")
property("sonar.organization", "ethauvin-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sourceEncoding", "UTF-8")
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml")
}
}
@ -61,15 +68,15 @@ val javadocJar by tasks.creating(Jar::class) {
}
tasks {
withType<JacocoReport> {
reports {
xml.isEnabled = true
html.isEnabled = true
}
withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
}
withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}
withType<GenerateMavenPom> {
@ -121,20 +128,20 @@ tasks {
register("deploy") {
description = "Copies all needed files to the $deployDir directory."
group = PublishingPlugin.PUBLISH_TASK_GROUP
dependsOn("build", "jar")
dependsOn(build, jar)
outputs.dir(deployDir)
inputs.files(copyToDeploy)
mustRunAfter("clean")
mustRunAfter(clean)
}
register("release") {
description = "Publishes version ${project.version} to local repository."
group = PublishingPlugin.PUBLISH_TASK_GROUP
dependsOn("wrapper", "deploy", "gitTag", "publishToMavenLocal")
dependsOn(wrapper, "deploy", gitTag, publishToMavenLocal)
}
"sonarqube" {
dependsOn("jacocoTestReport")
dependsOn(koverReport)
}
}
@ -164,7 +171,7 @@ publishing {
scm {
connection.set("scm:git:git://github.com/$gitHub.git")
developerConnection.set("scm:git:git@github.com:$gitHub.git")
url.set("$mavenUrl")
url.set(mavenUrl)
}
issueManagement {
system.set("GitHub")
@ -176,13 +183,15 @@ publishing {
repositories {
maven {
name = "ossrh"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
url = if (project.version.toString().contains("SNAPSHOT"))
uri("https://oss.sonatype.org/content/repositories/snapshots/") else
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials(PasswordCredentials::class)
}
}
signing {
useGpgCmd()
sign(publishing.publications[publicationName])
}
}
signing {
useGpgCmd()
sign(publishing.publications[publicationName])
}

View file

@ -1,11 +1,11 @@
<?xml version="1.0" ?>
<?xml version='1.0' encoding='UTF-8'?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>LongParameterList:ReadingTime.kt$ReadingTime$( text: String, wpm: Int = 275, var postfix: String = "min read", var plural: String = "min read", excludeImages: Boolean = false, extra: Int = 0, var roundingMode: RoundingMode = RoundingMode.HALF_EVEN )</ID>
<ID>MagicNumber:ReadingTime.kt$ReadingTime$10</ID>
<ID>MagicNumber:ReadingTime.kt$ReadingTime$12</ID>
<ID>MagicNumber:ReadingTime.kt$ReadingTime$3</ID>
<ID>MagicNumber:ReadingTime.kt$ReadingTime$60</ID>
<ID>MagicNumber:ReadingTime.kt$ReadingTime$60.0</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -1,11 +1,13 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.31"
id("com.github.ben-manes.versions") version "0.38.0"
application
id("application")
id("com.github.ben-manes.versions") version "0.42.0"
kotlin("jvm") version "1.7.10"
}
// ./gradlew run --args="example.html"
// ./gradlew runJava --args="example.html"
// ./gradlew run
// ./gradlew runJava
repositories {
mavenLocal()
@ -13,22 +15,31 @@ repositories {
}
dependencies {
implementation("net.thauvin.erik:readingtime:0.9.0")
implementation("net.thauvin.erik:readingtime:0.9.1-SNAPSHOT")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
application {
mainClassName = "com.example.ReadingTimeExampleKt"
mainClass.set("com.example.ReadingTimeExampleKt")
}
tasks {
getByName<JavaExec>("run") {
args = listOf("${project.projectDir}/example.html")
withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
}
named<JavaExec>("run") {
args = listOf("${project.projectDir}/example.html")
}
register<JavaExec>("runJava") {
group = "application"
main = "com.example.ReadingTimeSample"
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("com.example.ReadingTimeSample")
classpath = sourceSets.main.get().runtimeClasspath
args = listOf("${project.projectDir}/example.html")
}
}

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

269
examples/gradlew vendored
View file

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,67 +17,101 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -106,80 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View file

@ -16,8 +16,8 @@ public class ReadingTimeSample {
rt.setPlural("minutes to read");
System.out.println("It will take " + rt.calcReadingTime() + ' ' + ReadingTime.wordCount(rt.getText())
+ " words and " + ReadingTime.imgCount(rt.getText()) + " images at " + rt.getWpm()
+ " words per minute.");
+ " words and " + ReadingTime.imgCount(rt.getText()) + " images at " + rt.getWpm()
+ " words per minute.");
} catch (IOException e) {
System.err.println("The file could not be read or found.");
}

View file

@ -13,7 +13,7 @@ fun main(args: Array<String>) {
println(
"It will take ${rt.calcReadingTime()} ${ReadingTime.wordCount(rt.text)} words and " +
"${ReadingTime.imgCount(rt.text)} images at ${rt.wpm} words per minute."
"${ReadingTime.imgCount(rt.text)} images at ${rt.wpm} words per minute."
)
} else {
System.err.println("The file could not be read or found.")

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

269
gradlew vendored
View file

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,67 +17,101 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -106,80 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

19
pom.xml
View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.thauvin.erik</groupId>
<artifactId>readingtime</artifactId>
<version>0.9.0</version>
<version>0.9.1-SNAPSHOT</version>
<name>readingtime</name>
<description>Estimated Reading Time for Blog Posts, Articles, etc.</description>
<url>https://github.com/ethauvin/readingtime</url>
@ -35,17 +35,28 @@
<system>GitHub</system>
<url>https://github.com/ethauvin/readingtime/issues</url>
</issueManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.7.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.30</version>
<version>1.7.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<version>1.15.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>

View file

@ -1,10 +1,18 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.5.1/userguide/multi_project_builds.html
*/
plugins {
id("com.gradle.enterprise").version("3.6.3")
}
gradleEnterprise {
buildScan {
link("GitHub", "https://github.com/ethauvin/readingtime/tree/master")
if (!System.getenv("CI").isNullOrEmpty()) {
isUploadInBackground = false
publishOnFailure()
tag("CI")
}
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
rootProject.name = "readingtime"

View file

@ -1,7 +1,7 @@
/*
* ReadingTime.kt
*
* Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
* Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -41,21 +41,25 @@ import java.math.RoundingMode
*
* Based on [Medium's calculation](https://blog.medium.com/read-time-and-you-bc2048ab620c).
*
* @constructor Constructs a new [ReadingTime] object.
*
* @param text The text to be evaluated.
* @param wpm The words per minute reading average.
* @param postfix The value to be appended to the reading time.
* @param plural The value to be appended if the reading time is more than 1 minute.
* @param excludeImages Images are excluded from the reading time when set.
* @param extra Additional seconds to be added to the total reading time.
* @param roundingMode The [RoundingMode] to apply. Default is [RoundingMode.HALF_DOWN].
*/
class ReadingTime @JvmOverloads constructor(
text: String,
wpm: Int = 275,
var postfix: String = "min read",
var plural: String = "min read",
excludeImages: Boolean = false,
extra: Int = 0
) {
text: String,
wpm: Int = 275,
var postfix: String = "min read",
var plural: String = "min read",
excludeImages: Boolean = false,
extra: Int = 0,
var roundingMode: RoundingMode = RoundingMode.HALF_EVEN
) {
companion object {
private const val INVALID: Double = -1.0
@ -107,6 +111,8 @@ class ReadingTime @JvmOverloads constructor(
/**
* Calculates and returns the reading time in seconds.
*
* `((word count / wpm) * 60) + images + extra`
*/
fun calcReadingTimeInSec(): Double {
if (readTime == INVALID) {
@ -119,9 +125,11 @@ class ReadingTime @JvmOverloads constructor(
/**
* Calculates and returns the reading time. (eg. 1 min read)
*
* `(reading time in sec / 60) + postfix`
*/
fun calcReadingTime(): String {
val time = BigDecimal((calcReadingTimeInSec() / 60.0)).setScale(0, RoundingMode.HALF_DOWN)
val time = BigDecimal((calcReadingTimeInSec() / 60.0)).setScale(0, roundingMode)
return if (time.compareTo(BigDecimal.ONE) == 1) {
"$time $plural".trim()
} else {
@ -129,6 +137,10 @@ class ReadingTime @JvmOverloads constructor(
}
}
/**
* 12 seconds for the first image, 11 for the second, and minus an additional second for each subsequent image.
* Any images after the tenth image are counted at 3 seconds.
*/
private fun calcImgReadingTime(): Int {
var time = 0
val imgCount = imgCount(text)

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0"
<taglib xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
<tlib-version>1.0</tlib-version>
<short-name>ReadingTime</short-name>

View file

@ -1,5 +1,5 @@
<%--
Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
See: https://erik.thauvin.net/licenses/bsd.shtml

View file

@ -1,7 +1,7 @@
/*
* ReadingTimeTest.kt
*
* Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
* Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -33,34 +33,22 @@
package net.thauvin.erik.readingtime
import java.io.File
import java.math.RoundingMode
import kotlin.test.Test
import kotlin.test.assertEquals
class ReadingTimeTest {
private val rt = ReadingTime("This is a <b>test</b>.\nWith an image: <img src=\"#\">")
private val img = """<img src="#">"""
private val rt = ReadingTime("This is a <b>test</b>.\nWith an image: $img")
private val blogPost = File("src/test/resources/post.html").readText()
private val mediumPost = File("src/test/resources/medium.html").readText()
private val twoSeventyFive = "one two three four five six seven eight nine ten one two three four five six seven " +
"eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine " +
"ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten one two " +
"three four five six seven eight nine ten one two three four five six seven eight nine ten one two three four " +
"five six seven eight nine ten one two three four five six seven eight nine ten one two three four five six " +
"seven eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight " +
"nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten " +
"one two three four five six seven eight nine ten one two three four five six seven eight nine ten one two " +
"three four five six seven eight nine ten one two three four five six seven eight nine ten one two three four " +
"five six seven eight nine ten one two three four five six seven eight nine ten one two three four five six " +
"seven eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight " +
"nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten " +
"one two three four five six seven eight nine ten one two three four five"
private val tenImages = "<img src=\"#\"> <img src=\"#\"> <img src=\"#\"> <img src=\"#\"> <img src=\"#\"> " +
"<img src=\"#\"> <img src=\"#\"> <img src=\"#\"> <img src=\"#\"> <img src=\"#\">"
private val twoSeventyFive = "word ".repeat(275)
private fun calcImgTime(imgCount: Int): Double {
var time = 0.0
var offset = 12
for (i in 1..imgCount) {
repeat(imgCount) {
time += offset
if (offset != 3) {
offset--
@ -75,100 +63,113 @@ class ReadingTimeTest {
@Test
fun testWordCount() {
assertEquals(0, ReadingTime.wordCount(" "))
assertEquals(3, ReadingTime.wordCount("one two three"))
assertEquals(2, ReadingTime.wordCount(" one two "))
assertEquals(7, ReadingTime.wordCount(rt.text))
assertEquals(505, ReadingTime.wordCount(blogPost))
assertEquals(391, ReadingTime.wordCount(mediumPost))
assertEquals(275, ReadingTime.wordCount(twoSeventyFive))
assertEquals(275, ReadingTime.wordCount("$twoSeventyFive <img src=\"#\""))
assertEquals(0, ReadingTime.wordCount(" "), "empty")
assertEquals(3, ReadingTime.wordCount("one two three"), "one two three")
assertEquals(2, ReadingTime.wordCount(" one two "), "one two")
assertEquals(7, ReadingTime.wordCount(rt.text), "text")
assertEquals(505, ReadingTime.wordCount(blogPost), "blogPost")
assertEquals(391, ReadingTime.wordCount(mediumPost), "mediumPost")
assertEquals(275, ReadingTime.wordCount(twoSeventyFive), "275")
assertEquals(275, ReadingTime.wordCount("$twoSeventyFive $img"), "275 + image")
}
@Test
fun testImgCount() {
assertEquals(1, ReadingTime.imgCount(rt.text))
assertEquals(11, ReadingTime.imgCount(blogPost))
assertEquals(3, ReadingTime.imgCount(mediumPost))
assertEquals(1, ReadingTime.imgCount("$twoSeventyFive <img src=\"#\""))
assertEquals(2, ReadingTime.imgCount("$twoSeventyFive <img src=\"#\"> <img src=\"#\">"))
assertEquals(1, ReadingTime.imgCount(rt.text), "text")
assertEquals(11, ReadingTime.imgCount(blogPost), "blogPost")
assertEquals(3, ReadingTime.imgCount(mediumPost), "mediumPost")
assertEquals(1, ReadingTime.imgCount("$twoSeventyFive $img"), "275 + image")
assertEquals(2, ReadingTime.imgCount("$twoSeventyFive $img $img"), "275 + 2 images")
}
@Test
fun testReadingTimeInSec() {
assertEquals(calcReadingTime(rt.text, rt.wpm) + calcImgTime(1), rt.calcReadingTimeInSec())
assertEquals(calcReadingTime(rt.text, rt.wpm) + calcImgTime(1), rt.calcReadingTimeInSec(), "text + image")
rt.text = "<img src=\"#\"> <IMG src=\"#\">"
assertEquals(calcImgTime(2), rt.calcReadingTimeInSec())
rt.text = "$img ${img.uppercase()}"
assertEquals(calcImgTime(2), rt.calcReadingTimeInSec(), "2 images")
rt.excludeImages = true
assertEquals(0.0, rt.calcReadingTimeInSec())
assertEquals(0.0, rt.calcReadingTimeInSec(), "image uppercase")
rt.excludeImages = false
rt.text = blogPost
assertEquals(
calcReadingTime(rt.text, rt.wpm) + calcImgTime(11), rt.calcReadingTimeInSec()
calcReadingTime(rt.text, rt.wpm) + calcImgTime(11), rt.calcReadingTimeInSec(), "blogPost"
)
rt.excludeImages = true
assertEquals(calcReadingTime(rt.text, rt.wpm), rt.calcReadingTimeInSec())
assertEquals(calcReadingTime(rt.text, rt.wpm), rt.calcReadingTimeInSec(), "exclude images")
rt.extra = 60
assertEquals(calcReadingTime(rt.text, rt.wpm) + 60L, rt.calcReadingTimeInSec())
assertEquals(calcReadingTime(rt.text, rt.wpm) + 60L, rt.calcReadingTimeInSec(), "extra 60")
rt.extra = 0
rt.excludeImages = false
rt.text = mediumPost
rt.wpm = 300
assertEquals(calcReadingTime(rt.text, 300) + calcImgTime(3), rt.calcReadingTimeInSec())
assertEquals(calcReadingTime(rt.text, 300) + calcImgTime(3), rt.calcReadingTimeInSec(), "mediumPost 300 wpm")
rt.wpm = 275
rt.text = "This is a test"
assertEquals(0.0, rt.calcReadingTimeInSec())
assertEquals(0.0, rt.calcReadingTimeInSec(), "test")
rt.text = twoSeventyFive
assertEquals(60.0, rt.calcReadingTimeInSec())
assertEquals(60.0, rt.calcReadingTimeInSec(), "275")
rt.text = "$twoSeventyFive <img src=\"#\">"
assertEquals(72.0, rt.calcReadingTimeInSec())
rt.text = "$twoSeventyFive $img"
assertEquals(72.0, rt.calcReadingTimeInSec(), "275 + image")
rt.text = "$twoSeventyFive <img src=\"#\"> <img src=\"#\">"
assertEquals(83.0, rt.calcReadingTimeInSec())
rt.text = "$twoSeventyFive $img $img"
assertEquals(83.0, rt.calcReadingTimeInSec(), "275 + 2 images")
rt.text = "$twoSeventyFive $tenImages"
assertEquals(60.0 + 12 + 11 + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3, rt.calcReadingTimeInSec())
rt.text = "$twoSeventyFive ${img.repeat(10)}"
assertEquals(60.0 + 12 + 11 + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3, rt.calcReadingTimeInSec(), "10 images")
rt.text = "$twoSeventyFive $tenImages <img src=\"#\">"
assertEquals(135.0 + 3, rt.calcReadingTimeInSec())
rt.text = "$twoSeventyFive ${img.repeat(10)} $img"
assertEquals(135.0 + 3, rt.calcReadingTimeInSec(), "11 images")
rt.text = "$twoSeventyFive $twoSeventyFive"
assertEquals(120.0, rt.calcReadingTimeInSec())
assertEquals(120.0, rt.calcReadingTimeInSec(), "275*2")
rt.text = ""
assertEquals(0.0, rt.calcReadingTimeInSec())
assertEquals(0.0, rt.calcReadingTimeInSec(), "empty")
rt.postfix = ""
assertEquals(rt.calcReadingTime(), rt.calcReadingTimeInSec().toInt().toString(), "toInt(0)")
}
@Test
fun testReadingTime() {
rt.text = blogPost
assertEquals("2 min read", rt.calcReadingTime())
assertEquals("2 min read", rt.calcReadingTime(), "blogPost")
rt.plural = "mins read"
assertEquals("2 mins read", rt.calcReadingTime())
assertEquals("2 mins read", rt.calcReadingTime(), "plural")
rt.text = mediumPost
rt.plural = ""
assertEquals("2", rt.calcReadingTime())
assertEquals("2", rt.calcReadingTime(), "mediumPost")
rt.text = "This is a test."
rt.postfix = ""
assertEquals("0", rt.calcReadingTime())
assertEquals("0", rt.calcReadingTime(), "test")
rt.text = ""
assertEquals("0", rt.calcReadingTime())
assertEquals("0", rt.calcReadingTime(), "empty")
rt.text = twoSeventyFive
assertEquals("1", rt.calcReadingTime())
assertEquals("1", rt.calcReadingTime(), "275")
rt.text = "$twoSeventyFive $twoSeventyFive"
assertEquals("2", rt.calcReadingTime())
assertEquals("2", rt.calcReadingTime(), "275 * 2")
}
@Test
fun testRoundingMode() {
rt.text = blogPost
rt.roundingMode = RoundingMode.UP
assertEquals("3 min read", rt.calcReadingTime(), "UP")
rt.text = mediumPost
rt.roundingMode = RoundingMode.DOWN
assertEquals("1 min read", rt.calcReadingTime(), "DOWN")
}
}

View file

@ -1,7 +1,7 @@
<section class="gx gy gz ha hb">
<div class="n p">
<div class="z ab ac ae af ht ah ai"><p id="d889"
class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct">
<div class="z ab ac ae af ht ah ai"><p class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct"
id="d889">
Eons ago, a couple of Medium engineers got fed up. They were sick of having to scroll all the way down the
page to see how long a story was. It was wearing out their trackpad, it was making their fingers sore, and
they figured there must be a better way. So they sat down and devised a simple formula, and the Medium read
@ -13,48 +13,48 @@
<div class="ls lt r">
<div class="cc lo s t u ex ai bv lp lq"><img alt="Image for post"
class="s t u ex ai lu lv lw"
src="https://miro.medium.com/max/60/1*wju0JzgNZVpPzZDgfchajg.png?q=20"
width="180" height="58"/></div>
<img alt="Image for post" class="cc lo s t u ex ai lx" width="180" height="58"/>
height="58"
src="https://miro.medium.com/max/60/1*wju0JzgNZVpPzZDgfchajg.png?q=20" width="180"/></div>
<img alt="Image for post" class="cc lo s t u ex ai lx" height="58" width="180"/>
<noscript><img alt="Image for post" class="s t u ex ai"
src="https://miro.medium.com/max/360/1*wju0JzgNZVpPzZDgfchajg.png"
width="180" height="58"/></noscript>
height="58"
src="https://miro.medium.com/max/360/1*wju0JzgNZVpPzZDgfchajg.png" width="180"/></noscript>
</div>
</div>
</div>
</div>
</figure>
<p id="8a5b" class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct">With the widespread
<p class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct" id="8a5b">With the widespread
adoption of this feature across the internet, we decided to shed some light on exactly what goes in to
our read time calculation.</p>
<blockquote class="ly"><p id="13d1" class="lz ma bj hw b mb mc md me mf mg ld bn">Read time is based on the
<blockquote class="ly"><p class="lz ma bj hw b mb mc md me mf mg ld bn" id="13d1">Read time is based on the
average reading speed of an adult (roughly 275 WPM). We take the total word count of a post and
translate it into minutes. Then, we add 12 seconds for each inline image. <strong class="ay">Boom, read
time.</strong></p></blockquote>
<p id="17fc" class="kq kr bj ks b ip mh ku is mi kw kx mj ix kz mk ja lb ml jd ld gx ct">Lately, we have
<p class="kq kr bj ks b ip mh ku is mi kw kx mj ix kz mk ja lb ml jd ld gx ct" id="17fc">Lately, we have
seen more and more long form stories containing a ton of images. With our release of <a
href="https://medium.com/the-story/introducing-image-grids-c592e5bc16d8"
class="cg dj mm mn mo mp" target="_blank" rel="noopener">image grids</a>, we expect even more of
class="cg dj mm mn mo mp"
href="https://medium.com/the-story/introducing-image-grids-c592e5bc16d8" rel="noopener" target="_blank">image grids</a>, we expect even more of
these types of essays.</p>
<p id="c072" class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct">Our original read
<p class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct" id="c072">Our original read
time calculation was geared toward “slow” images, like comics, where you would really want to sit down
and invest in the image. This resulted in articles with crazy big read times. For instance, this <a
href="https://medium.com/@dahul/inside-medium-94931f66eebd" class="cg dj mm mn mo mp"
target="_blank" rel="noopener">article</a> containing 140 images was clocking in at a whopping
class="cg dj mm mn mo mp" href="https://medium.com/@dahul/inside-medium-94931f66eebd"
rel="noopener" target="_blank">article</a> containing 140 images was clocking in at a whopping
87 minute read. So we amended our read time calculation to count 12 seconds for the first image, 11 for
the second, and minus an additional second for each subsequent image. Any images after the tenth image
are counted at three seconds.</p>
<p id="fbc9" class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct">You might see this
<p class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct" id="fbc9">You might see this
change reflected across the site. Keep in mind that our estimated read time is just that: <em
class="mq">an estimation</em>. You might finish a story faster or slower depending on various
factors such as how many children or cats you have, your caffeine/alcohol intake, or if youre a
time-traveler from the future and already read that story. We just want to give you a ballpark figure so
you can decide whether you have time to read one more story before the bus comes, or if you should
bookmark it for later.</p>
<p id="369b" class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct">We arent done with
<p class="kq kr bj ks b ip kt ku is kv kw kx ky ix kz la ja lb lc jd ld gx ct" id="369b">We arent done with
read time yet. In the future, wed like to tailor it to your reading speed, account for the <a
href="https://medium.com/@fchimero/this-should-only-take-a-minute-or-four-probably-e38bb7bf2adf"
class="cg dj mm mn mo mp" target="_blank" rel="noopener">complexity of an article</a>, and add
class="cg dj mm mn mo mp"
href="https://medium.com/@fchimero/this-should-only-take-a-minute-or-four-probably-e38bb7bf2adf" rel="noopener" target="_blank">complexity of an article</a>, and add
support for other languages. Well be sure to let you know about these changes as they happen.</p></div>
</div>
</section>

View file

@ -11,11 +11,13 @@
<dt>Definition list</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
commodo consequat.
</dd>
<dt>Lorem ipsum dolor sit amet</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
commodo consequat.
</dd>
</dl>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam,