ReactiveX/RxScala — pull request #70 by zsxwing (2014-12-02 05:40:51+00:00)
Title: Fix the height issue of the img tags

Fix #69.

![docs](https://cloud.githubusercontent.com/assets/1000778/5258414/c4ceb902-7a28-11e4-992d-6622d907fb0e.png)

The new img tags are generated by the following codes:

```Scala
import java.io.File
import java.net.URL
import javax.swing.ImageIcon

import scala.io._
import scala.collection.mutable

object Main {

def imageMeta(imgURL: String): (Int, Int) = {
val imageIcon = new ImageIcon(new URL(imgURL))
(imageIcon.getIconWidth(), imageIcon.getIconHeight())
}

def clearImg(file: String): Unit = {

val img = """""".r

val urlImgCache = mutable.Map[String, String]()

for (line <- Source.fromFile(new File(file))(Codec.UTF8).getLines()) {
val newLine = img.findFirstMatchIn(line) map {
imgTag => {
val tagContent = imgTag group 0
val url = imgTag group 1
val newImgTag = if (urlImgCache.contains(url)) {
urlImgCache(url)
} else {
val (width, height) = imageMeta(url)
val ratio = 640.0 / width
val scaleHeight = (height * ratio).toInt
val newImgTag = s""""""
urlImgCache += url -> newImgTag
newImgTag
}
line.replace(tagContent, newImgTag)
}
} getOrElse (line)
println(newLine)
}
}

def main(args: Array[String]): Unit = {
clearImg("/home/zsx/workspace/RxScala/src/main/scala/rx/lang/scala/Observable.scala")
}
}
```