diff --git a/src/emitter.c b/src/emitter.c
index b78246a7500fba0c5f794a8164798cf56b0e7b6d_c3JjL2VtaXR0ZXIuYw==..6c0f5c49ef59f3b436e7890fbf61ca3f7db3b677_c3JjL2VtaXR0ZXIuYw== 100644
--- a/src/emitter.c
+++ b/src/emitter.c
@@ -603,8 +603,14 @@
             implicit = 0;
             if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
                 return 0;
-            if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0))
-                return 0;
+            if (event->data.document_start.version_directive->minor == 1) {
+                if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0))
+                    return 0;
+            }
+            else {
+                if (!yaml_emitter_write_indicator(emitter, "1.2", 1, 0, 0))
+                    return 0;
+            }
             if (!yaml_emitter_write_indent(emitter))
                 return 0;
         }
diff --git a/tests/run-emitter-test-suite.c b/tests/run-emitter-test-suite.c
index b78246a7500fba0c5f794a8164798cf56b0e7b6d_dGVzdHMvcnVuLWVtaXR0ZXItdGVzdC1zdWl0ZS5j..6c0f5c49ef59f3b436e7890fbf61ca3f7db3b677_dGVzdHMvcnVuLWVtaXR0ZXItdGVzdC1zdWl0ZS5j 100644
--- a/tests/run-emitter-test-suite.c
+++ b/tests/run-emitter-test-suite.c
@@ -3,8 +3,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
+#include "../src/yaml_private.h"
 
 int get_line(FILE * input, char *line);
 char *get_anchor(char sigil, char *line, char *anchor);
 char *get_tag(char *line, char *tag);
 void get_value(char *line, char *value, int *style);
@@ -6,11 +7,12 @@
 
 int get_line(FILE * input, char *line);
 char *get_anchor(char sigil, char *line, char *anchor);
 char *get_tag(char *line, char *tag);
 void get_value(char *line, char *value, int *style);
+int usage(int ret);
 
 int main(int argc, char *argv[])
 {
     FILE *input;
     yaml_emitter_t emitter;
     yaml_event_t event;
@@ -11,10 +13,11 @@
 
 int main(int argc, char *argv[])
 {
     FILE *input;
     yaml_emitter_t emitter;
     yaml_event_t event;
+    yaml_version_directive_t *version_directive = NULL;
 
     int canonical = 0;
     int unicode = 0;
     char line[1024];
@@ -17,5 +20,8 @@
 
     int canonical = 0;
     int unicode = 0;
     char line[1024];
+    int foundfile = 0;
+    int i = 0;
+    int minor = 0;
 
@@ -21,3 +27,30 @@
 
-    if (argc == 1)
+    for (i = 1; i < argc; i++) {
+        if (strncmp(argv[i], "--help", 6) == 0)
+            return usage(0);
+        if (strncmp(argv[i], "-h", 2) == 0)
+            return usage(0);
+        if (strncmp(argv[i], "--directive", 11) == 0) {
+            if (i+1 == argc)
+                return usage(1);
+            i++;
+            if (strncmp(argv[i], "1.1", 3) == 0)
+                minor = 1;
+            else if (strncmp(argv[i], "1.2", 3) == 0)
+                minor = 2;
+            else
+                return usage(1);
+        }
+        else if (!foundfile) {
+            input = fopen(argv[i], "rb");
+            foundfile = 1;
+        }
+
+    }
+    if (minor) {
+        version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
+        version_directive->major = 1;
+        version_directive->minor = minor;
+    }
+    if (!foundfile)
         input = stdin;
@@ -23,10 +56,5 @@
         input = stdin;
-    else if (argc == 2)
-        input = fopen(argv[1], "rb");
-    else {
-        fprintf(stderr, "Usage: libyaml-emitter [<input-file>]\n");
-        return 1;
-    }
+
     assert(input);
 
     if (!yaml_emitter_initialize(&emitter)) {
@@ -37,6 +65,7 @@
     yaml_emitter_set_canonical(&emitter, canonical);
     yaml_emitter_set_unicode(&emitter, unicode);
 
+
     while (get_line(input, line)) {
         int ok;
         char anchor[256];
@@ -51,7 +80,7 @@
         }
         else if (strncmp(line, "+DOC", 4) == 0) {
             implicit = strncmp(line, "+DOC ---", 8) != 0;
-            ok = yaml_document_start_event_initialize(&event, NULL, NULL, NULL, implicit);
+            ok = yaml_document_start_event_initialize(&event, version_directive, NULL, NULL, implicit);
         }
         else if (strncmp(line, "-DOC", 4) == 0) {
             implicit = strncmp(line, "-DOC ...", 8) != 0;
@@ -229,3 +258,8 @@
     }
     value[i] = '\0';
 }
+
+int usage(int ret) {
+    fprintf(stderr, "Usage: run-emitter-test-suite [--directive (1.1|1.2)] [<input-file>]\n");
+    return ret;
+}