{
    generalSettings: {
        enableDoubleRenderingOutline:   "true",
        bodiesToRender:   "//body",
        //bodiesToRender:   "//body[empty(@name) or @name != 'notes']",
        generateTOCLevels:	"2",
        generateFrontMatter:	"true",
        generateNoteBackLinks:	"true",
        generateInternalLinks:  "true",
        transliterateMetaInfo:	"true",
        forceTransliterateAuthor: "false",
        metaAuthorQuery: "(last-name, first-name,  middle-name)",
        imageDpi: 168.212,  // PRS-500/505/600/700/650/900/950, Kindle, Nook
        //imageDpi: 200,    // PRS-300/350
        //imageDpi: 150,    // Kindle DX
        //imageDpi: 212,    // PRS-T3, Kindle Paperwhite, iRiver Story HD
        //imageDpi: 300,    // Kindle Voyage
        stretchCover: "true",
        enableInlineImages: "false",
        fullCompression: "false",
        trackingSpaceCharRatio: 10000000, //Inter-character spacing disabled with 10000000
        overrideImageTransparency: "",
        makeGrayImageTransparent: "false",
        cacheImages:    "false",
        ignoreEmptyLineBeforeImage: "true",
        ignoreEmptyLineAfterImage: "true",
        strictImageSequence:	"false",
        enableLinkPageNum:      "false",
        linkPageNumFormat:  "[%04d]",
        enableTOCPageNum:   "true",
        tocPageNumFormat:  "%04d",
        linkPageNumMax:     9999,
        hangingPunctuation: ".,;:'-"
    },
    fontFamilies: [
        {
            name:         "sansSerif",
            regular:      "./data/FreeSans.ttf",
            bold:         "./data/FreeSansBold.ttf",
            italic:       "./data/FreeSansOblique.ttf",
            boldItalic:   "./data/FreeSansBoldOblique.ttf"
        },
        {
            name:         "serif",
            regular:      "./data/NotoSerif-Regular.ttf",
            bold:         "./data/NotoSerif-Bold.ttf",
            italic:       "./data/NotoSerif-Italic.ttf",
            boldItalic:   "./data/NotoSerif-BoldItalic.ttf"
        },
        {
            name:         "monospaced",
            regular:      "./data/LiberationMono-Regular.ttf",
            bold:         "./data/LiberationMono-Bold.ttf",
            italic:       "./data/LiberationMono-Italic.ttf",
            boldItalic:   "./data/LiberationMono-BoldItalic.ttf"
        }
        /*
        {
            name:         "sansSerif",
            regular:      "c:/windows/fonts/calibri.ttf",
            bold:         "c:/windows/fonts/calibrib.ttf",
            italic:       "c:/windows/fonts/calibrii.ttf",
            boldItalic:   "c:/windows/fonts/calibriz.ttf"
        },
        {
            name:         "serif",
            regular:      "c:/windows/fonts/CAMBRIA.TTC,0",
            bold:         "c:/windows/fonts/CAMBRIAB.TTF",
            italic:       "c:/windows/fonts/CAMBRIAI.TTF",
            boldItalic:   "c:/windows/fonts/CAMBRIAZ.TTF"
        },
        {
            name:         "monospaced",
            regular:      "c:/windows/fonts/consola.ttf",
            bold:         "c:/windows/fonts/consolab.ttf",
            italic:       "c:/windows/fonts/consolai.ttf",
            boldItalic:   "c:/windows/fonts/consolaz.ttf"
        }
        */
    ],
    pageStyle: {
        //values: 0, 90, 180, 270
        //usually has no visual effect, only PDF internals are different
        pageRotation:   "0", 

        // PRS-500/505/600/700/650 Portrait
        pageWidth:    "88.184mm",
        pageHeight:   "113.854mm",
        
        // PRS-500/505/600/700/650 Landscape
        //pageWidth:    "118.384mm",
        //pageHeight:   "83.654mm",
        
        // PRS-300/350 Portrait
        //pageWidth:    "74.168mm",
        //pageHeight:   "95.758mm",

        // PRS-300/350 Landscape
        //pageWidth:    "99.568mm",
        //pageHeight:   "70.358mm",

        // PRS-900/950 Portrait
        //pageWidth:    "88.184mm",
        //pageHeight:   "147.678mm",

        // PRS-900/950 Landscape
        //pageWidth:    "152.208mm",
        //pageHeight:   "83.654mm",

        // PRS-900/950 Landscape 2-column
        //pageWidth:    "75.802mm",
        //pageHeight:   "83.654mm",

        // PRS-T3 Portrait
        //pageWidth:    "88.184mm",
        //pageHeight:   "114.356mm",       

        // Kindle 3/4 Portrait  (calculated from 560x735 pixels of 0.151mm; another variant is 85.09mm x 111.76mm, yet another variant is 85.5mm x 112.3mm)
        //pageWidth:    "84.560mm",
        //pageHeight:   "110.985mm",

        // Kindle 3/4 Landscape  (calculated from 722x535 pixels of 0.151mm)
        //pageWidth:    "109.022mm",
        //pageHeight:   "80.785mm",

        // Kindle DX Portrait
        //pageWidth:    "132.757mm",
        //pageHeight:   "194.733mm",

        // Kindle DX Landscape
        //pageWidth:    "196.427mm",
        //pageHeight:   "131.064mm",

        //Kindle Paperwhite Portrait 
        // calculated from 658x904 pixels of 0.1198 mm
        //pageWidth:      "78.836mm", 
        //pageHeight:      "108.310mm", 

        // Kindle Paperwhite Landscape 
        // calculated from 924x638 pixels of 0.1198 mm
        // pageWidth:      "110.706mm", 
        // pageHeight:      "76.440mm",

        //Kindle Paperwhite 2013 (FW ver. 5.4.3.2) Portrait calculated from 718x964 pixels, side margins ~2mm
        //pageWidth:      "86.025mm", 
        //pageHeight:     "115.498mm", 

        // Kindle Voyage Portrait (small margins) 
        // calculated from 1016x1364 pixels of 0,0847 mm 
        //pageWidth:   "86.021mm", 
        //pageHeight:   "115.485mm",

        // Kindle Voyage Landscape (small margins) 
        // calculated from 1322x988 pixels of 0,0847 mm 
        //pageWidth:   "111.929mm", 
        //pageHeight:   "83.651mm",

        // Pocketbook Touch 
        //pageWidth:    "84mm",
        //pageHeight:   "106mm",

        marginLeft:   "1.0pt",
        marginRight:  "1.0pt",
        marginTop:    "0.0pt",
        marginBottom: "1.0pt",
        imageExtraMargins: "10pt",
        marginMirroring: "false",
        sectionNewPage: {
        	"0": 1.0,
        	"1": 0.5
        },

        backgroundColor: "",
        backgroundImage: "",
        header: {          
            enabled: "false",
            dynamic: "true",
            //chapterTitle: "(ancestor-or-self::section)[2]/title//*[name()!='a']/text()", 
            //chapterTitle: "string-join(ancestor-or-self::section/title[.//text()[matches(., '[^\\d\\s]')]]//*[name()!='a']/text(), '. ')",
            chapterTitle: "replace(string-join(ancestor-or-self::section/title//*[name()!='a']/text(), '. '), '([^\\s\\w])\\. ', '$1 ')",
            leftOdd:   {
                enabled:        "true",
                style:          "headerLeft",
                border:         2, // TOP = 1; BOTTOM = 2; LEFT = 4; RIGHT = 8; NO_BORDER = 0; BOX = TOP + BOTTOM + LEFT + RIGHT;
                borderColor:    "0x000000",
                // There are predefined variables $bookTitle, $authorFullName, $authorLastName, $authorFirstLastName, $authorFirstInitialLastName, $authorAllInitialsLastName
                // There are predefined dynamic variables $pageNum, $chapterTitle
                // There are predefined custom functions fb:cut-right(string, length) fb:cut-left(string, length)
                // There are standard xquery functions http://www.w3schools.com/xpath/xpath_functions.asp
                //query:          "string-join(($authorFirstLastName, $bookTitle), ', ')" 
                query:          "fb:cut-right($authorFirstLastName, 30)" 
            },
            centerOdd: {
                enabled:        "false"
            },
            rightOdd:  {
                enabled:        "true",
                style:          "headerRight",
                query:          "fb:cut-right($bookTitle, 30)"
            },
            leftEven:   {
                enabled:        "true",
                query:          "fb:cut-right($chapterTitle, 45)"
            },
            centerEven: {
                enabled:        "false"
            },
            rightEven:  {
                enabled:        "true",
                style:          "headerRight",
                query:          "$pageNum"
            }
        },

        enforcePageSize: "false",
        pageSizeEnforcerColor: "0x7F7F7F",
        footnotes:      "false",
        footnotesMaxLines:      7,
        footnoteMaxLines:       999,
        tableCellsAutoWidth:    false,
        preventWidows:	"true"
    },
    hyphenationSettings: {
        defaultLanguage:	"ru",
        hyphenate: 	  		"true",
        overrideLanguage:	"false"
    },
    transformationSettings: {
        enabled:					"false",
        outputDebugFile:            "false",
        queryProlog:                "declare default element namespace \"http://www.gribuser.ru/xml/fictionbook/2.0\"; declare namespace l = \"http://www.w3.org/1999/xlink\"; ",
        morpherProlog:              "declare default element namespace \"http://www.gribuser.ru/xml/fictionbook/2.0\"; declare namespace l = \"http://www.w3.org/1999/xlink\"; ",
        transformationsMap: [
                /*
                {   // make digits superscript in notes (depends on font)
                    "query":   "//a[@type='note']/text()", 
                    "morpher": "translate(., '0123456789', '\u2070\u00B9\u00B2\u00B3\u2074\u2075\u2076\u2077\u2078\u2079')" 
                },
                */
                /* 
                {   // delete dash (with following space) when dash is first character of first paragraph of the section
                    "query":   "//p[1]/text()", 
                    "morpher": "replace(., '^(\u2012|\u2013|\u2014|\u2015)(\u00A0|\\s)*', '')" 
                },
                */ 
                /*
                { //delete bracket at the end of the text node 
                  "query": "//text()[ends-with(., '[')]", 
                  "morpher": "replace(., '(.*)\\[$', '$1')" 
                }, 
                { //delete bracket at the beginning of the text node 
                  "query": "//text()[starts-with(., ']')]", 
                  "morpher": "replace(., '^\\](.*)', '$1')" 
                },
                */              
                /*
                {   // convert poem note to paragraphs, part 1
                    "query":   "//body[@name='notes']//section/poem",
                    "morpher": ".//stanza/*"
                },
                {   // convert poem note to paragraphs, part 2
                    "query":   "//body[@name='notes']//section/v",
                    "morpher": "<p>{./* | text()}</p>"
                },
                */
                /*
                {   // delete links with empty href
                    "query":   "//a[@l:href='']",
                    "morpher": "()"
                },
                */
                /*
                {   // merge notes bodies, part 1
                    "query":   "//body[@name='notes']",
                    "morpher": "<body name='notes'>{//body[@name='notes' or @name='footnotes']/*}</body>"
                },
                {   // merge notes bodies, part 2
                    "query":   "//body[@name='footnotes']",
                    "morpher": "()"
                },
                */
                /*
                {   // fix image-wrapped-in-paragraph
                    "query":   "//p[exists(image) and count(*) = 1]",
                    "morpher": "./*"
                },
                */
                /*
                {   // convert table cells to paragraphs 
                    "query":   "//td", 
                    "morpher": "<p>{./* | text()}</p>" 
                }, 
                {   // convert table headers to paragraphs 
                    "query":   "//th", 
                    "morpher": "<p>{./* | text()}</p>" 
                }, 
                {   // remove table rows 
                    "query":   "//tr", 
                    "morpher": "./*" 
                }, 
                {   // remove table 
                    "query":   "//table", 
                    "morpher": "./*" 
                },
                */                
                /*
                {   //add empty title to the sections without title
                    "query":    "//section[empty(./title)]/*[position()=1]",
                    "morpher":  "(<title><p/></title>,.)"
                },
                */
                /*
                {   // remove square brackets from note link
                    "query":   "//a[@type='note']/text()",
                    "morpher": "replace(., '[\\[\\]]', '')"
                },
                */
                /*
                {   // remove word "note" from note link
                    "query":   "//a[@type='note']/text()",
                    "morpher": "replace(., 'note', '')"
                },
                */
                /*
                {   // remove extra spaces from note link
                    "query":   "//a[@type='note']/text()",
                    "morpher": "normalize-space(.)"
                },
                */
                /*
                {   // make note links superscript 
                    "query":   "//a[(@type='note' or @type='comment') and not(parent::sup or child::sup)]/text()", 
                    "morpher":   "<sup>{.}</sup>" 
                },
                */
                /*
                {   // replace note link with note text 
                    "query":   "//a[@type='note']",
                    "morpher": "declare variable $hid := ./@l:href; <emphasis> [{//body[@name='notes']//section[@id=substring($hid,2)]/*[local-name()!='title']}]</emphasis>"
                },
                */
                /*
                {   // get rid of superscript inside note link
                    "query":   "//a[@type='note']//sup",
                    "morpher": "./* | text()"
                },
                */
                /*
                {   // get rid of superscript outside note link
                    "query":   "//sup[./a[@type='note']]",
                    "morpher": "./a"
                },
                */
                /*
                {   //replace emphasis inside cite with it's text
                    "query":   "//cite//emphasis",
                    "morpher": "./text()"
                },
                */
                /*
                {   //remove images
                    "query":   "//image",
                    "morpher": "()"
                },
                */
                /*
                {   // wrap notes body content in two sections, making notes third-level section
                    "query":   "//body[@name='notes']",
                    "morpher": "<body name='notes'><section><section>{./*}</section></section></body>"
                },
                */
                /*
                {   // add new line before and after "code" 
                    "query":   "//code",
                    "morpher": "<code>{('\n', ./* | text(), '\n')}</code>"
                },
                */
                /*
                {   // replace a single root section of nameless (main) body with it's content
                    "query":    "//body[empty(@name) and count(section) = 1]/section",
                    "morpher":  "./*"
                },
                */
                /*
                {   // load image from external file
                    "query":   "//binary", 
                    "morpher": "(., <binary id='new-cover.jpg' content-type='image/jpg'>{fb:load-binary('./data/NewCover.jpg')}</binary>)" 
                },
                {   // replace cover image
                    "query":   "//coverpage/image/@l:href", 
                    "morpher": "attribute {'l:href'} {'#new-cover.jpg'}" 
                },
                */
        ]
    },
    textPreprocessorSettings: {
        enabled:					"true",
        makeEndUnbreakable:			"false",
        makeReplacements:			"true",
        replacementsMap: {
                //"\"(.*?)\"": "«$1»", //replacing quotes
                " \u2012 ": "\u00A0\u2012 ",
                " \u2013 ": "\u00A0\u2013 ",
                " \u2014 ": "\u00A0\u2014 ",
                " \u2015 ": "\u00A0\u2015 ",
                " \u2212 ": "\u00A0\u2212 ",
                " \u2010 ": "\u00A0\u2010 ",
                " \u002D ": "\u00A0\u002D " 
                //below is commented out because doesn't look good on narrow page
                /*
                " \u0430 ": " \u0430\u00A0", 
                " \u0432 ": " \u0432\u00A0", 
                " \u0438 ": " \u0438\u00A0", 
                " \u043A ": " \u043A\u00A0", 
                " \u043E ": " \u043E\u00A0", 
                " \u0441 ": " \u0441\u00A0", 
                " \u0443 ": " \u0443\u00A0", 
                " \u0410 ": " \u0410\u00A0", 
                " \u0411\u0435\u0437 ": " \u0411\u0435\u0437\u00A0", 
                " \u0412 ": " \u0412\u00A0", 
                " \u0412\u043E ": " \u0412\u043E\u00A0", 
                " \u0414\u0430 ": " \u0414\u0430\u00A0", 
                " \u0414\u043E ": " \u0414\u043E\u00A0", 
                " \u0414\u043B\u044F ": " \u0414\u043B\u044F\u00A0", 
                " \u0417\u0430 ": " \u0417\u0430\u00A0", 
                " \u0418 ": " \u0418\u00A0", 
                " \u0418\u0437 ": " \u0418\u0437\u00A0", 
                " \u0418\u043B\u0438 ": " \u0418\u043B\u0438\u00A0", 
                " \u041A ": " \u041A\u00A0", 
                " \u041A\u043E ": " \u041A\u043E\u00A0", 
                " \u041A\u0430\u043A ": " \u041A\u0430\u043A\u00A0", 
                " \u041D\u0430 ": " \u041D\u0430\u00A0", 
                " \u041D\u043E ": " \u041D\u043E\u00A0", 
                " \u041D\u0430\u0434 ": " \u041D\u0430\u0434\u00A0", 
                " \u041F\u043E ": " \u041F\u043E\u00A0", 
                " \u041F\u043E\u0434 ": " \u041F\u043E\u0434\u00A0", 
                " \u041F\u0440\u0438 ": " \u041F\u0440\u0438\u00A0", 
                " \u041E ": " \u041E\u00A0", 
                " \u041E\u0442 ": " \u041E\u0442\u00A0", 
                " \u0420\u0430\u0437 ": " \u0420\u0430\u0437\u00A0", 
                " \u0421 ": " \u0421\u00A0", 
                " \u0422\u0430\u043A ": " \u0422\u0430\u043A\u00A0", 
                " \u0422\u043E ": " \u0422\u043E\u00A0", 
                " \u0422\u0443\u0442 ": " \u0422\u0443\u0442\u00A0", 
                " \u0423 ": " \u0423\u00A0", 
                " \u0427\u0435\u043C ": " \u0427\u0435\u043C\u00A0", 
                " \u0427\u0442\u043E ": " \u0427\u0442\u043E\u00A0"
                */		
        }
    },
    paragraphStyles: [
        {
            name:             "default",
            fontFamily:       "sansSerif",
            color:            "0x000000",  
            strokeWidth:      "0.0",  
            characterSpacing: "0.0",  
            horizontalScaling:"1.0",  
            inlineImageZoom:    "1.0",
            inlineImageOffsetY: "0.0",
            fontSize:         "14.0pt"
        },
        {
            comment:          "Front matter style: authors, publishers, uuid, creator tool",
            name:             "frontMatter",
            baseStyle:        "default",
            fontSize:         "66%"
        },
        {
            name:             "title",
            baseStyle:        "default",
            fontStyle:        "bold",
            fontSize:         "150%",
            alignment:        "center"
        },
        {
            name:             "subtitle",
            baseStyle:        "default",
            fontSize:         "110%",
            alignment:        "center"
        },
        {
            name:             "author",
            baseStyle:        "default",
            fontSize:         "130%",
            alignment:        "center"
        },
        {
            name:             "tocTitle",
            baseStyle:        "default",
            fontSize:         "150%",
            alignment:        "center",
            spacingAfter:     "1em",
            text:             "\u0421\u043E\u0434\u0435\u0440\u0436\u0430\u043D\u0438\u0435"
        },
        {
            name:             "tocItem",
            baseStyle:        "body",
            alignment:        "left",
            firstFirstLineIndent:  "0pt",
            firstLineIndent:  "0pt",
            fontSize:         "90%"
        },
        {
            name:             "annotation",
            baseStyle:        "default",
            fontFamily:       "serif",
            fontSize:         "80%",
            alignment:        "justified",
            firstSpacingBefore:   "0.3em",
            spacingAfter:     "0.3em"
        },
        {
            name:             "annotationSubtitle",
            baseStyle:        "annotation",
            fontFamily:       "sansSerif",
            fontStyle:        "bold",
            alignment:        "center",
            spacingBefore:    "0.3em",
            spacingAfter:     "0.3em"
        },
        {
            name:             "bodyTitle",
            baseStyle:        "default",
            fontSize:         "150%",
            fontStyle:        "bold",
            alignment:        "center",
            lastSpacingAfter:     "0.6em",
            disableHyphenation: "true"
        },
        {
            name:             "sectionTitle",
            baseStyle:        "default",
            fontSize:         "150%",
            fontStyle:        "bold",
            alignment:        "center",
            lastSpacingAfter:     "0.6em",
            disableHyphenation: "true"
        },
        {
            name:             "subSectionTitle",
            baseStyle:        "default",
            fontSize:         "120%",
            fontStyle:        "bold",
            alignment:        "center",
            spacingBefore:        "0.3em",
            firstSpacingBefore:   "0.6em",
            lastSpacingAfter:     "0.6em",
            disableHyphenation: "true"
        },
        {
            name:             "subSubSectionTitle",
            baseStyle:        "default",
            fontSize:         "110%",
            fontStyle:        "bold",
            alignment:        "center",
            disableHyphenation: "true"
        },
        {
            name:             "poem",
            baseStyle:        "default",
            fontFamily:       "serif",
            fontStyle:        "italic",
            leftIndent:       "5.0em",
            firstLineIndent:  "0em",
            firstFirstLineIndent:  "0em",
            firstSpacingBefore:   "0.5em",
            lastSpacingAfter:     "0.5em"
        },
        /*
        {
            name:             "poemAuthor",
            selector:         "//poem/text-author"
        },
        */
        /*
        {
            name:             "poemTitle",
            selector:         "//poem/title"
        },
        */
        /*
        {
            name:             "poemDate",
            selector:         "//poem/date"
        },
        */
        {
            name:             "epigraph",
            baseStyle:        "default",
            fontFamily:       "serif",
            fontStyle:        "italic",
            leftIndent:       "2.5em",
            firstSpacingBefore:   "0.5em",
            lastSpacingAfter:     "0.5em"
        },
        /*
        {
            name:             "epigraphAuthor",
            selector:         "//epigraph/text-author"
        },
        */
        {
            name:             "cite",
            baseStyle:        "epigraph"
        },
        {
            name:             "citeSubtitle",
            selector:         "//cite/subtitle",  
            fontStyle:        "boldItalic"
        },
        /*
        {
            name:             "citeAuthor",
            selector:         "//cite/text-author"
        },
        */
        {
            name:             "body",
            baseStyle:        "default",
            fontFamily:       "serif",
            fontSize:         "95%",
            alignment:        "justified",
            firstLineIndent:  "1.5em",
            leading:          "1.2em",
            firstFirstLineIndent:  "0em",
            dropcapStyle:	  "bodyDropCap"	
        },
        {
            name:             "header",
            baseStyle:        "default",
            fontFamily:       "serif",
            fontSize:         "70%",
            fontStyle:        "italic",
            spacingAfter:     "3pt",
            spacingBefore:    "0pt",
            leftIndent:       "3pt",    
            rightIndent:      "3pt"
        },
        {
            name:             "headerLeft",
            baseStyle:        "header",
            alignment:        "left"
        },
        {
            name:             "headerRight",
            baseStyle:        "header",
            alignment:        "right"
        },
        {
            name:               "code",
            selector:           "//code",
            fontFamily:         "monospaced"
        },
        {
            name:               "codeParagraph",
            selector:           "//p[code and count(*) = 1 and empty(text())]",
            baseStyle:          "body",
            fontFamily:         "monospaced",
            fontSize:           "55%",
            alignment:          "left",
            disableHyphenation: "true",
            preserveWhitespaces: "true",
            dropcapStyle:	  ""	
        },
        /*
        {
            name:               "anchor",
            selector:           "//a[@type='note']",
            fontFamily:         "sansSerif"
        },
        */
        {
            name:             "table",
            baseStyle:        "body",
            leftIndent:       "0.5em",  
            rightIndent:      "0.5em",  
            spacingBefore:    "0.5em",
            spacingAfter:     "0.5em"
        },
        {
            name:             "tableTD",
            baseStyle:        "body"
        },
        {
            name:             "tableTH",
            baseStyle:        "body",
            fontStyle:        "bold"
        },
        {
            name:             "footnote",
            baseStyle:        "default",
            fontFamily:       "sansSerif",
            fontSize:         "70%",
            alignment:        "justified",
            firstFirstLineIndent:  "0pt",
            firstLineIndent:  "1em",
            leading:          "1.1em",
            dropcapStyle:	  ""	
        },
       	{
       		name:			"bodyDropCap",
            baseStyle:      "default",
            enabled: 	    "true",
       		fontFamily:		"serif",
       		fontSize:		"233%",
       		fontStyle:		"regular",
       		spacingBefore:  "6.6pt",
       		spacingAfter:	"1.0pt"
       	},
        {
            name:             "bodySubtitle",
            baseStyle:        "default",
            fontFamily:       "sansSerif",
            fontSize:         "120%",
            fontStyle:        "bold",
            alignment:        "center",
            spacingBefore:    "0.3em",
            spacingAfter:     "0.3em"
        }            
    ]
}
