Repository: kivy/kivy

Issue:
Label markup + valign not working
I am using a subclassed Label, and when i use

```
markup: True
valign: "bottom"
```

it aligns the text at the top instead. If i comment out the markup 

```
#markup: True
valign: "bottom"
```

it aligns correctly at the bottom of the label bounding box



Discussion:

Resolving patch:
diff --git a/kivy/core/text/markup.py b/kivy/core/text/markup.py
--- a/kivy/core/text/markup.py
+++ b/kivy/core/text/markup.py
@@ -260,22 +260,33 @@ def _real_render(self):
         r = self._render_text
 
         # convert halign/valign to int, faster comparaison
-        #av = {'top': 0, 'middle': 1, 'bottom': 2}[self.options['valign']]
+        av = {'top': 0, 'middle': 1, 'bottom': 2}[self.options['valign']]
         ah = {'left': 0, 'center': 1, 'right': 2}[self.options['halign']]
 
         y = 0
         w, h = self._size
         refs = self._refs
+        no_of_lines = len(self._lines)-1
+
         for line in self._lines:
             lh = line[1]
+            lw = line[0]
 
             # horizontal alignement
             if ah == 0:
                 x = 0
             elif ah == 1:
-                x = int((w - line[0]) / 2)
+                x = int((w - lw) / 2)
             else:
-                x = w - line[0]
+                x = w - lw
+
+            # vertical alignement
+            if y == 0:
+                if av == 1:
+                    y = int((h - (lh*no_of_lines))/2)
+                elif av == 2:
+                    y = h - (lh*(no_of_lines))
+
 
             for pw, ph, part, options in line[2]:
                 self.options = options
diff --git a/kivy/uix/rst.py b/kivy/uix/rst.py
--- a/kivy/uix/rst.py
+++ b/kivy/uix/rst.py
@@ -146,6 +146,7 @@ def run(self):
 
 <RstTitle>:
     markup: True
+    valign: 'top'
     font_size: 24 - self.section * 2
     size_hint_y: None
     height: self.texture_size[1] + 20
@@ -162,6 +163,7 @@ def run(self):
 
 <RstParagraph>:
     markup: True
+    valign: 'top'
     size_hint_y: None
     height: self.texture_size[1] + self.my
     text_size: self.width - self.mx, None
@@ -174,6 +176,7 @@ def run(self):
         id: label
         text: root.text
         markup: True
+        valign: 'top'
         size_hint: None, None
         size: self.texture_size[0] + 10, self.texture_size[1] + 10
 
@@ -210,6 +213,7 @@ def run(self):
     Label:
         id: content
         markup: True
+        valign: 'top'
         text_size: self.width - 20, None
         font_name: 'data/fonts/DroidSansMono.ttf'
         color: (0, 0, 0, 1)
@@ -296,6 +300,7 @@ def run(self):
 
 <RstFieldName>:
     markup: True
+    valign: 'top'
     size_hint: None, 1
     color: (0, 0, 0, 1)
     bold: True
@@ -343,6 +348,7 @@ def run(self):
 
 <RstListBullet>:
     markup: True
+    valign: 'top'
     size_hint_x: None
     width: self.texture_size[0] + 10
     text_size: None, self.height - 10
@@ -431,8 +437,8 @@ class RstDocument(ScrollView):
     when a rst document is explicitly loaded, or where :func:`preload` has been
     called.
 
-    If the document has no filename, e.g., when the document is loaded from a text file,
-    the key will be ''.
+    If the document has no filename, e.g., when the document is loaded from a
+    text file, the key will be ''.
 
     :data:`toctrees` is a :class:`~kivy.properties.DictProperty`, default to {}.
     '''
@@ -541,10 +547,10 @@ def goto(self, ref, *largs):
 
         .. note::
 
-            It is preferable to delay the call of the goto if you just loaded the
-            document, because the layout might not be finished, or if the size
-            of the RstDocument is not fixed yet, then the calculation of the
-            scrolling would be wrong.
+            It is preferable to delay the call of the goto if you just loaded
+            the document, because the layout might not be finished, or if the
+            size of the RstDocument is not fixed yet, then the calculation of
+            the scrolling would be wrong.
 
             However, you can do a direct call if the document is already loaded.
 
@@ -687,6 +693,7 @@ class RstTransition(Widget):
 class RstEmptySpace(Widget):
     pass
 
+
 class RstDefinitionSpace(Widget):
     pass
 


Test patch: