Merge "Create a Command Files page"
diff --git a/scripts/build.py b/scripts/build.py
index 12bcb98..33a1e33 100755
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -14,21 +14,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import os
+import codecs
 import glob
+import markdown
+import os
 import shutil
 import string
 import subprocess
 
 
-# call markdown as a subprocess, and capture the output
-def markdown(raw_file):
-  extensions = '-x tables -x "toc(title=In This Document)" -x def_list'
-  command = 'markdown' + ' ' + extensions + ' ' + raw_file
-  p = subprocess.Popen(command, stdout = subprocess.PIPE, shell = True)
-  return p.communicate()[0]
-
-
 # read just the title (first heading) from a source page
 def get_title(raw_file):
   for line in open(raw_file, 'r'):
@@ -63,6 +57,11 @@
 category = 'home'
 parents = {}
 for curdir, subdirs, files in os.walk(SRC_DIR):
+  def md(path):
+    text = codecs.open(path, encoding='utf8').read()
+    extensions = ['tables', 'def_list', 'toc(title=In This Document)']
+    return markdown.markdown(text, extensions)
+
   print 'Processing %s...'  % (curdir,),
   # Step A: split path, and update cached category name if needed
   curdir = os.path.normpath(curdir)
@@ -86,19 +85,19 @@
     parent = ('', '', '')
 
   if 'sidebar.md' in files:
-    sidebar = markdown(os.path.join(curdir, 'sidebar.md'))
+    sidebar = md(os.path.join(curdir, 'sidebar.md'))
     del files[files.index('sidebar.md')]
   else:
     sidebar = parent[0]
 
   if 'sidebar2.md' in files:
-    sidebar2 = markdown(os.path.join(curdir, 'sidebar2.md'))
+    sidebar2 = md(os.path.join(curdir, 'sidebar2.md'))
     del files[files.index('sidebar2.md')]
   else:
     sidebar2 = parent[1]
 
   if 'sidebar3.md' in files:
-    sidebar3 = markdown(os.path.join(curdir, 'sidebar3.md'))
+    sidebar3 = md(os.path.join(curdir, 'sidebar3.md'))
     del files[files.index('sidebar3.md')]
   else:
     sidebar3 = parent[2]
@@ -112,15 +111,14 @@
     absfilename = os.path.join(curdir, f)
 
     if f.endswith('.md'):
-      main = markdown(absfilename)
+      main = md(absfilename)
       final = template.safe_substitute(main=main, sidebar=sidebar, sidebar2=sidebar2, \
           sidebar3=sidebar3, category=category, title=get_title(absfilename))
 
-      html = file(os.path.join(outdir, f.replace('.md', '.html')), 'w')
+      html = codecs.open(os.path.join(outdir, f.replace('.md', '.html')), 'w', encoding="utf8")
       html.write(final)
     else:
       shutil.copy(absfilename, os.path.join(outdir, f))
   print
 
 print 'Done.'
-
diff --git a/src/source/building-devices.md b/src/source/building-devices.md
index 9b69575..1de1e61 100644
--- a/src/source/building-devices.md
+++ b/src/source/building-devices.md
@@ -244,10 +244,10 @@
 4.0.1 (ITL41D)  | PRIMEKJ10            | I9250XXKK1
 4.0.2 (ICL53F)  | PRIMEKK15            | I9250XXKK6      | All previous versions
 4.0.3 (IML74K)  | PRIMEKL01            | I9250XXKK6      | All previous versions
-4.0.4 (IMM76D)  | PRIMEKL03            | I9250XXLA02
-4.0.4 (IMM76I)  | PRIMEKL03            | I9250XXLA02
-4.0.4 (IMM76K)  | PRIMEKL03            | I9250XXLA02
-4.0.4 (IMM76L)  | PRIMEKL03            | I9250XXLA02
+4.0.4 (IMM76D)  | PRIMELA03            | I9250XXLA02
+4.0.4 (IMM76I)  | PRIMELA03            | I9250XXLA02
+4.0.4 (IMM76K)  | PRIMELA03            | I9250XXLA02
+4.0.4 (IMM76L)  | PRIMELA03            | I9250XXLA02
 
 If you're building a new version of Android, if your Nexus S or
 Galaxy Nexus has
diff --git a/src/tech/input/input-device-configuration-files.md b/src/tech/input/input-device-configuration-files.md
index 0a477d0..be6900a 100644
--- a/src/tech/input/input-device-configuration-files.md
+++ b/src/tech/input/input-device-configuration-files.md
@@ -62,7 +62,7 @@
 *   `/data/system/devices/idc/DEVICE_NAME.idc`
 
 When constructing a file path that contains the device name, all characters
-in the device name other than '0'-'9', 'a'-'z', 'A'-'Z', '-' or '_' are replaced by '_'.
+in the device name other than '0'-'9', 'a'-'z', 'A'-'Z', '-' or '\_' are replaced by '\_'.
 
 ## Syntax ##