On 06/29/2016 10:11 PM, Scott Kostyshak wrote:
> On Thu, Jun 30, 2016 at 03:48:01AM +0200, Richard Heck wrote:
>> commit ddc28f0374478355217f975a25e544af7dbc8ea9
>> Author: Richard Heck <[email protected]>
>> Date:   Wed Jun 29 21:47:51 2016 -0400
>>
>>     Output column width info for XHTML.
>> ---
>>  src/insets/InsetTabular.cpp |    7 +++++++
>>  1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
>> index 7728a1a..7804232 100644
>> --- a/src/insets/InsetTabular.cpp
>> +++ b/src/insets/InsetTabular.cpp
>> @@ -2993,6 +2993,13 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, 
>> row_type row,
>>                      continue;
>>  
>>              stringstream attr;
>> +            
>> +            Length const cwidth = column_info[c].p_width;
>> +            if (!cwidth.zero()) {
>> +                    string const hwidth = cwidth.asHTMLString();
>> +                    attr << "style =\"width: " << hwidth << ";\" ";
>> +            }
>> +            
>>              attr << "align='";
>>              switch (getAlignment(cell)) {
>>              case LYX_ALIGN_LEFT:
> I just tested and it works well. Is there a reason to specify the column
> width for each row instead of just for each column? In the sample
> document at #8168, the HTML output now contains four instances of '3cm'.
> Ideally shouldn't it just contain one? For example, as specified at [1].

Try this:

--- src/insets/InsetTabular.cpp
+++ src/insets/InsetTabular.cpp
@@ -2989,17 +2989,20 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs,
row_type row,
 
     xs << html::StartTag("tr");
     for (col_type c = 0; c < ncols(); ++c) {
+        bool didone = false;
         if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c))
             continue;
 
         stringstream attr;
        
         Length const cwidth = column_info[c].p_width;
-        if (!cwidth.zero()) {
+        if (!didone && !cwidth.zero()) {
             string const hwidth = cwidth.asHTMLString();
             attr << "style =\"width: " << hwidth << ";\" ";
         }
        
+        didone = true;
+       
         attr << "align='";
         switch (getAlignment(cell)) {
         case LYX_ALIGN_LEFT:

If it works, go ahead and put it in.

Richard

Reply via email to